Ver Mensaje Individual
  #1 (permalink)  
Antiguo 04/06/2011, 13:59
privatefta
(Desactivado)
 
Fecha de Ingreso: septiembre-2010
Mensajes: 498
Antigüedad: 13 años, 8 meses
Puntos: 5
duda al actualizar fecha date

saludos es que llevo tanto tiempo con este problema

mira es que tengo este código

para actualizar las tablas

Código PHP:
Ver original
  1. if (isset($_POST["renovuser"]) and $_POST["renovuser"] == "Renovar") {
  2.     $username = "";
  3.     $userid = "";
  4.     $username = "";
  5.     $creditos= "";
  6.    
  7.     $userid = $_POST["uid"];
  8.     $username = $_POST["username"];
  9.     $creditos = strtolower($_POST["creditos"]);
  10.  
  11.     $conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
  12.     mysql_select_db($dbname, $conn);
  13.  
  14. // Esla linia es la que estoy tratando que que al selecionar del 1 al 6 actualizae la fecha sumandole meses.
  15.  
  16.     $sql = mysql_query("UPDATE clientes SET expiredate='".date("Y-m-d", mktime(0, 0, 0, date("m")+".$creditos.", date("d"), date("Y")))."', changed='".date('Y-m-d H:i')."', changedby='".$_SESSION["loginuser"]."' WHERE id='".$userid."'") or die ("Error editing user");
  17.     $sql2 = mysql_query("UPDATE admins SET creditos= creditos - '".$creditos."' WHERE username='".$_SESSION["loginuser"]."'") or die ("Error editing admin user");
  18.     mysql_close($conn);
  19.     $status = "Usuario ".$username." Renovado!";
  20. }

y este es el formulario

Código PHP:
Ver original
  1. <?php
  2. require("includes/logincheck.php");
  3. require("config.php");
  4. require("includes/settings.php");
  5.  
  6. if (isset($_GET["id"]) <> "") {
  7.     $userid = $_GET["id"];
  8. } else {
  9.     header( "Location: controlpanel.php" );
  10. }
  11. ?>
  12. <html xmlns="http://www.w3.org/1999/xhtml">
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  15. <title>.:: Administrador de Usuarios ::.</title>
  16. <link rel="shortcut icon" href="images/favicon.ico">
  17. </head>
  18.  
  19. <body onLoad="focus();edituser.username.focus()" background="images/bg.png">
  20. <table width="850" border="3" align="center" bgcolor="#FFFFFF">
  21. <tr>
  22. <td align="center">
  23. <?php require("includes/header.php"); ?>
  24. </td>
  25. </tr>
  26. <tr>
  27. <td>
  28.   <div align="center"><br />
  29.       <font size="6"><b>Administrador de Usuarios </b></font>
  30.       <br />
  31.     <br />
  32.   </div>    <br />
  33.   <div align="right">
  34.   <table width="240" border="3">
  35.   <tr>
  36.     <th scope="col"><font size=-1>&nbsp;<b>Usuario Iniciado:</b> <?php echo $_SESSION["loginuser"] ; ?></font></th>
  37.     <th scope="col"><font size=-1><a href='logout.php'>Logout</a></font></th>
  38.   </tr>
  39. </table>
  40.   </div>    <br />
  41.   <table width="800" border="2" align="center">
  42.   <tr>
  43.     <td><div align="center"><b>Renovar Usuario (<a href="controlpanel.php">Regresar al Panel Principal</a>)</b></div></td>
  44.   </tr>
  45.   <td>
  46.     <form name="renovar" action="controlpanel.php" method="post">
  47.     <?php
  48.     $conn = @mysql_connect($dbhost,$dbuser,$dbpass) or die ("Error connecting to database");
  49.     mysql_select_db($dbname, $conn);
  50.     $sql = mysql_query("SELECT * FROM clientes WHERE id='".$userid."'");
  51.     $line=mysql_fetch_array($sql);
  52.     $sql2 = mysql_query("SELECT * FROM admins WHERE username='".$_SESSION["loginuser"]."'");
  53.     $cred=mysql_fetch_array($sql2);
  54.     mysql_close($conn);
  55.     ?>
  56.     <input type="hidden" name="uid" value="<?php print($line["id"]); ?>">
  57.     <input type="hidden" name="username" value="<?php print($line["name"]); ?>"><br>
  58.     Nombre:<br>
  59.     <strong><?php print($line["name"]); ?></strong>
  60.     <br><br>
  61.     Creditos Disponibles:<br>
  62.     <b><font color="#FF0000">( <u><?php print($cred["creditos"]); ?></u> )</font> </b>
  63.         <br><br>
  64.      Renovar Cuenta:<br>
  65.     <input type="text" name="addfin" size="10" tabindex="1" value="<?php print($line["expiredate"]); ?>" readonly>
  66.      <br><br>
  67.          Renovar:<br>
  68.         <select name="creditos">
  69.         <option value="1">1</option>
  70.         <option value="2">2</option>
  71.         <option value="3">3</option>
  72.         <option value="4">4</option>
  73.         <option value="5">5</option>
  74.         <option value="6">6</option>
  75.     </select>
  76.       &nbsp;Meses<br>
  77.         <input type="submit" name="renovuser" value="Renovar" tabindex="2" class="submit" accesskey="r" title="(ALT+r)">
  78.       </form>
  79.   </td>
  80. </tr>
  81. </table>
  82. <hr>
  83. <div align="center">
  84. <?php
  85. require("includes/footer.php");
  86. ?></div>
  87. </td>
  88. </tr>
  89. </table>
  90. </td>
  91. </tr>
  92. </table>
  93. </body>
  94. </html>

hay les dejo a ver que es lo que estoy haciendo mal ya que no suma el mes lo que hace es actualizar la fecha a la que esta actual.