Cita:
CREATE TABLE `registro` (
`id` int(10) unsigned NOT NULL auto_increment,
`nombre` char(20) collate latin1_general_ci NOT NULL,
`apellidos` char(20) collate latin1_general_ci NOT NULL,
`fecha` date NOT NULL,
`email` char(20) collate latin1_general_ci NOT NULL,
`usuario` char(20) collate latin1_general_ci NOT NULL,
`password` char(20) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;
`id` int(10) unsigned NOT NULL auto_increment,
`nombre` char(20) collate latin1_general_ci NOT NULL,
`apellidos` char(20) collate latin1_general_ci NOT NULL,
`fecha` date NOT NULL,
`email` char(20) collate latin1_general_ci NOT NULL,
`usuario` char(20) collate latin1_general_ci NOT NULL,
`password` char(20) collate latin1_general_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=3 ;
Cita:
mi problema es k cuando registro a alguien y pongo el usuario y la ontraseña m sale el error siguiente:<form action="ingresar.php" method="post">
<input type="text" name="user" size="15" maxlength="15">
<input type="password" name="pass" size="15" maxlength="15">
<input type="submit" value="enviar"></div></td>
</form>
<input type="text" name="user" size="15" maxlength="15">
<input type="password" name="pass" size="15" maxlength="15">
<input type="submit" value="enviar"></div></td>
</form>
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /...../...../..../...../ingresar.php on line 17
la line 17 corresponde a
Código PHP:
if (mysql_num_rows($result) >0 )
{
// si están en la base de datos registra la id de usuario
$valid_user = $usuario;
session_register("valid_user");
}
Código PHP:
<?
session_start();
$usuario=$_POST['user'];
$password=$_POST['pass'];
if ($usuario && $password)
{
// Si el usuario ha intentado hacer log in
$db_conn = mysql_connect("localhost", "xxxxx", "yyyyy");
mysql_select_db("registro", $db_conn);
$consulta = "select * from usuarios "
."where usuario='$usuario' "
." and password='$password' ";
$result = mysql_query($consulta, $db_conn);
if (mysql_num_rows($result) >0 )
{
// si están en la base de datos registra la id de usuario
$valid_user = $usuario;
session_register("valid_user");
}
}
?>