Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/06/2006, 13:51
Newbie123
 
Fecha de Ingreso: junio-2006
Mensajes: 2
Antigüedad: 17 años, 10 meses
Puntos: 0
Desacuerdo No encuentro el error en este script

Hola!

Adapté éste script sobre registro de usuarios, cambiandole solamente los campos en la base de datos.
Lo pueden ver funcionando aqui:
usmlug.awardspace.com/usmlug/uregistrar.php

Cuando lleno los datos y me registro, dice que fue exitoso, pero cuando consulto la base de datos aparece vacia siempre.

Alguien detecta un error significativo!?

No logro hacerlo funcionar.

Saludos.

María P.

<?
if($_POST[enviar]) {
require 'config.php' ;
function quitar($texto) {
$texto = trim($texto) ;
$texto = htmlspecialchars($texto) ;
$texto = str_replace(chr(160),'',$texto) ; # Elimina espacios que no pueden ser borrados por trim()
return $texto ;
}
$cedula = quitar($_POST[cedula]) ;
$email = quitar($_POST[email]) ;
$con = mysql_query("select count(cedula) from usuarios where cedula='$cedula' or email='$email'") ;
if(mysql_result($con,0,0)) {
echo 'La cédula o el email ya están registrados. Haz click <a href="javascript:history.back()">aquí</a> para regresar.' ;
}
else {
$nombres = quitar($_POST[nombres]) ;
$apellidos = quitar($_POST[apellidos]) ;
$telefono = quitar($_POST[telefono]) ;
mysql_query("insert into usuarios (cedula,nombres,apellidos,email,telefono) values ('$cedula','$nombres','$apellidos','$email','$tele fono'") ;
echo 'Has sido registrad@. Haz click aquí <a href="index.php">aquí</a> para regresar a la página principal.' ;
}
}
else {
?>
<script>
function revisar() {


if(!/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(formulario.email.value)) {
alert('Debes poner un email válido.') ;
return false ;
}
}
</script>
<form name="formulario" method="post" action="<?=$_SERVER[PHP_SELF]?>" onsubmit="return revisar()">
<b>Cedula:</b><br>
<input type="text" name="cedula" maxlength="20"><br>
<b>Nombres:</b><br>
<input type="text" name="nombres" maxlength="10">
<br>
<b>Apellidos:</b><br>
<input type="text" name="apellidos" maxlength="10">
<br>
<b>Email:</b><br>
<input type="text" name="email" maxlength="40"><br>
<b>Tel&eacute;fono:</b><br>
<input type="text" name="telefono" maxlength="40" />
<br>
<br>
<input type="submit" name="enviar" value="Registrar">
</form>
</div>
<?
}