Ver Mensaje Individual
  #10 (permalink)  
Antiguo 02/02/2009, 06:31
Avatar de Marvin
Marvin
Colaborador
 
Fecha de Ingreso: febrero-2005
Ubicación: global $Chile->Santiago;
Mensajes: 1.991
Antigüedad: 19 años, 3 meses
Puntos: 81
Respuesta: ayuda con codigo por favor

Las etiquetas code estan en "Avanzado" o puedes poner "[ highlight= php ]" y el cierre "[ / highlight]" para los codigos php.

Ahora... una buena manera de hacer revisiones sobre archivos php es acostumbrarse a indentar el codigo:
Código php:
Ver original
  1. <?php
  2.  
  3. include("config.php");
  4. error_reporting(E_ALL ^ E_NOTICE);
  5.  
  6. $msg = Array();
  7. $error = Array();
  8.  
  9. function addUser(){
  10.     if (empty($_POST)) return false;
  11.     global $config, $msg, $error;
  12.     if (empty($_POST['login'])) $error[] = 'Error, You forgot to enter a account name!';
  13.     if (empty($_POST['password'][0]) || empty($_POST['password'][1])) $error[] = 'Error, You forgot to enter a password!';
  14.     if ($_POST['password'][0] !== $_POST['password'][1]) $error[] = 'Password does not match!';
  15.     if (!empty($error)) return false;
  16.     $db = @mysql_connect($config['mysql_host'], $config['mysql_user'], $config['mysql_pass']);
  17.     if (!$db) return $error[] = 'Database: '.mysql_error();
  18.     if (!@mysql_select_db($config['mysql_dbname'], $db)) return $error[] = 'Database: '.mysql_error();
  19.     $query = "SELECT `acct` FROM `accounts` WHERE `login` = '".mysql_real_escape_string($_POST['login'])."'";
  20.     $res = mysql_query($query, $db);
  21.     if (!$res) return $error[] = 'Database: '.mysql_error();
  22.     if (mysql_num_rows($res) > 0) return $error[] = 'Username already in use.';
  23.     //Modified by Jerq
  24.     $query = "INSERT INTO `accounts` (`login`,`password`,`lastip`, `flags`) VALUES ('".mysql_real_escape_string($_POST['login'])."', '".mysql_real_escape_string($_POST['password'][0])."', '".$_SERVER['REMOTE_ADDR']."','".mysql_real_escape_string($_POST['tbc'][0])."')";
  25.     //Modified by Jerq
  26.    
  27.     $res = mysql_query($query, $db);
  28.     if (!$res) return $error[] = 'Database: '.mysql_error();
  29.     $msg[] = 'The Account <span style="color:#00FF00"><strong>'.htmlentities($_POS T['login']).'</strong></span> has been created!';
  30.     mysql_close($db);
  31.     return true;
  32. }
  33.  
  34. addUser();
  35.  
  36. ?>
  37. <html xmlns="http://www.w3.org/1999/xhtml" >
  38.     <head>
  39.         <title>Pagina de registro de cuentas</title>
  40.         <meta http-equiv="Pragma" content="no-cache"/>
  41.         <meta http-equiv="Cache-Control" content="no-cache"/>
  42.         <style type="text/css" media="screen">
  43.             @import url(server_stats.css);.Estilo1 {color: #000000}
  44.             .Estilo2 {color: #1B1B1B}
  45.         </style>
  46.         <!--[if lt IE 7.]>
  47.             <script defer type="text/javascript" src="pngfix.js"></script>
  48.         <![endif]-->
  49.     </head>
  50.     <body>
  51.         <center>
  52.             <div class="logo">
  53.                 <p>&nbsp;</p>
  54.                 <p>&nbsp;</p>
  55.             </div>
  56.             <div style="width:300px">
  57.                 <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
  58.                     <table width="100%" border="0" cellspacing="1" cellpadding="3">
  59.                     <tr class="head">
  60.                         <th colspan="2"><span class="Estilo2">Creacion de Cuentas</span></th>
  61.                     </tr>
  62.                     <tr>
  63.                         <th><span class="Estilo1">Nombre de usuario: </span></th>
  64.                         <td align="center"><input class="button" type="text" name="login" size="30" maxlength="16"/></td>
  65.                     </tr>
  66.                     <tr>
  67.                         <th><span class="Estilo1">Contraseña: </span></th>
  68.                         <td align="center"><input class="button" type="password" name="password[]" size="30" maxlength="16"/></td>
  69.                     </tr>
  70.                     <tr>
  71.                         <th><input name="button" type="button" class="button" onClick="history.go(-1)" value="Atras" /></th>
  72.                         <td align="center"><input name="Input" type="submit" class="button" value="Crear"/></td>
  73.                     </tr>
  74.                     <tr>
  75.                         <th height="25">&nbsp;</th>
  76.                         <td align="center">&nbsp;</td>
  77.                     </tr>
  78.                     <tr>
  79.                         <th height="25">&nbsp;</th>
  80.                         <td align="center">&nbsp;</td>
  81.                     </tr>
  82.                     </table>
  83.                 </form>
  84.         <?php
  85.             if (!empty($error)){
  86.                 echo '<table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td class="error" align="center">';
  87.                 foreach($error as $text)
  88.                     echo $text.'</br>';
  89.                 echo '</td></tr></table>';
  90.             }
  91.             if (!empty($msg)){
  92.                 echo '<table width="100%" border="0" cellspacing="1" cellpadding="3"><tr><td align="center">';
  93.                 foreach($msg as $text)
  94.                     echo $text.'</br>';
  95.                 echo '</td></tr></table>';
  96.                 exit();
  97.             }
  98.         ?>
  99.             </div>
  100.         </center>
  101.         <p style="width: 220px; font-weight: bold; color: #29b503; font-family: tahoma, arial, sans; font-size: 13px;">
  102.         <p style="width: 220px; font-weight: bold; color: #29b503; font-family: tahoma, arial, sans; font-size: 13px;">
  103.         <br /><br /><br />
  104.     </body>
  105. </html>

Si esto no funciona, dinos que error es el que dice tu pagina... pueden ser muchas cosas y por lo mismo conviene que vayas de a poco.

Suerte!
__________________
El que dice "Solo sé que nada sé", esta asumiendo que sabe algo.
Lea las FAQ's!