09/12/2010, 09:30
|
| | | Fecha de Ingreso: febrero-2010
Mensajes: 43
Antigüedad: 14 años, 8 meses Puntos: 0 | |
Loggeo en PHP Hola estoy haciendo un sistema de autentificacion por loggin.
Soy nuevo o novato en php!
Aqui el codigo!
Codigo para el PHP registrarse
-------------------------------------------------------------------------------------------------------
<?php
session_start();
if(isset($_SESSION["conectado"])){
header("Location: index.php");
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript">
function validar(){
var user = document.registrarse-form.user.value;
var pass1 = document.registrarse-form.pass1.value;
var pass2 = document.registrarse-form.pass2.value;
var nombre = document.registrarse-form.nombre.value;
var apellido = document.registrarse-form.apellido.value;
var mail = document.registrarse-form.mail.value;
if(user == '' || pass1 == '' || pass2 == '' || nombre == '' || apellido == '' || mail == ''){
alert('Debes completar todos los campos !');
return false;
}else{
if(pass1 != pass2){
alert('Las contraseñas ingresadas son distintas !');
return false;
}else{
return true;
}
}
}
</script>
</head>
<body>
<p><a href="index.php">Home</a></p>
<br />
<?php
if($_SERVER['REQUEST_METHOD'] == 'POST'){
$user = mysql_real_escape_string($_POST["user"]);
$pass = mysql_real_escape_string($_POST["pass1"]);
$nombre = mysql_real_escape_string($_POST["nombre"]);
$apellido = mysql_real_escape_string($_POST["apellido"]);
$mail = mysql_real_escape_string($_POST["mail"]);
mysql_connect("localhost","root","" );
mysql_select_db("iskalti");
mysql_query("INSERT INTO login(usuario,password,nombre,apellido,mail) VALUES ('$user','$pass','$nombre','$apellido','$mail')");
mysql_close();
}else{ ?>
<form name="registrarse-form" action="" method="post" onSubmit="return validar();" >
<label for="user">Usuario: </label><input type="text" id="user" name="user" size="30" maxlength="20" /><br />
<label for="pass1">Password: </label><input type="password" id="pass1" name="pass1" size="30" maxlength="30" /><br />
<label for="pass2">Repetir Password: </label><input type="password" id="pass2" name="pass2" size="30" maxlength="30" /><br />
<label for="nombre">Nombre: </label><input type="text" id="nombre" name="nombre" size="30" maxlength="15" /><br />
<label for="apellido">Apellido: </label><input type="text" id="apellido" name="apellido" size="30" maxlength="30" /><br />
<label for="mail">Mail: </label><input type="text" id="mail" name="mail" size="50" maxlength="50" /><br /><br />
<input type="submit" value="Registrarse" /><input type="reset" value="Resetear" />
</form>
<?php } ?>
</body>
</html>
-------------------------------------------------------------------------------------------------------
Me aparece el iguiente error al al momento de agregar y/o registrarme en la base de datos:
-------------------------------------------------------------------------------------------------------
<code>
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\formularios\registrarse.php on line 52
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\formularios\registrarse.php on line 52
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\formularios\registrarse.php on line 53
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\formularios\registrarse.php on line 53
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\formularios\registrarse.php on line 54
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\formularios\registrarse.php on line 54
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\formularios\registrarse.php on line 55
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\formularios\registrarse.php on line 55
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: Access denied for user 'ODBC'@'localhost' (using password: NO) in C:\xampp\htdocs\formularios\registrarse.php on line 56
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in C:\xampp\htdocs\formularios\registrarse.php on line 56
</code>
------------------------------------------------------------------------------------------------------- |