Ver Mensaje Individual
  #1 (permalink)  
Antiguo 27/11/2015, 11:28
Arratia25
 
Fecha de Ingreso: noviembre-2015
Mensajes: 1
Antigüedad: 8 años, 5 meses
Puntos: 0
Login en PHP para mejora de sus Estructura!!!

Hola quisiera emigrar ese login a una forma moderna el cual pueda utilizar está conexión


*Pero en el Servidor me da este error

Deprecated:mysql_connect(): the mysql extesion is deprecat and will be removed in the future use mysqli or pdo instead in

Yo borre la conexión y coloque mi conexión actual la cual es pero me dice Usuario no excite! :/ tengo problemas porque necesito este login AYUDENME POR FA

<?php
$servername="localhost";
$username="root";
$password="clave";
$database="basededatos";
// Crear la conexión

$conn = new mysqli ($servername, $username, $password, $database);
$conn->query("SET NAMES 'utf8'");

// Verificar la conexión
if($conn->connect_error){
die("Error de Conexión:".$conn->connect_error);
}
?>


***************index.php************************** **
<!DOCTYPE html>
<html>
<head>

<meta charset="utf-8">
<link rel="stylesheet" href="bootstrap/css/bootstrap.css">
<link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.css">
<link rel="stylesheet" type="text/css" href="estilos/estilos.css">
<title>Proyecto</title>
</head>
<body background="images/golf.jpg" style="background-attachment: fixed" >
<center><div class="tit"><h2 style="color: #0000FF; ">Inicio de sesión</h2>
<center><div class="Ingreso">

<table border="0" align="center" valign="middle">
<tr>
<td rowspan=2>
<form action="validar.php" method="post">

<table border="0">

<tr><td><label style="font-size: 14pt"><b>Correo: </b></label></td>
<td width=80> <input class="form-group has-success" style="border-radius:15px;" type="text" name="mail"></td></tr>
<tr><td><label style="font-size: 14pt"><b>Contraseña: </b></label></td>
<td witdh=80><input style="border-radius:15px;" type="password" name="pass"></td></tr>
<tr><td></td>
<td width=80 align=center><input class="btn btn-primary" type="submit" value="Aceptar"></td>
</tr></tr></table>
</form>
<br>
<!-- formulario registro -->

<form method="post" action="" >
<fieldset>
<legend style="font-size: 18pt"><b>Registro</b></legend>
<div class="form-group">
<label style="font-size: 14pt"><b>Ingresa tu nombre</b></label>
<input type="text" name="realname" class="form-control" placeholder="Ingresa tu nombre" />
</div>
<div class="form-group">
<label style="font-size: 14pt; color: #FFFFFF;"><b>Ingresa tu email</b></label>
<input type="text" name="nick" class="form-control" required placeholder="Ingresa mail"/>
</div>
<div class="form-group">
<label style="font-size: 14pt; color: #FFFFFF;"><b>Ingresa tu Password</b></label>
<input type="password" name="pass" class="form-control" placeholder="Ingresa contraseña" />
</div>
<div class="form-group">
<label style="font-size: 14pt"><b>Repite tu contraseña</b></label>
<input type="password" name="rpass" class="form-control" required placeholder="repite contraseña" />
</div>

</div>

<input class="btn btn-danger" type="submit" name="submit" value="Registrarse"/>

</fieldset>
</form>
</div>
<?php
if(isset($_POST['submit'])){
require("registro.php");
}
?>
<!--Fin formulario registro -->

</td>
</tr>
</table>
</div></center></div></center>


</body>
</html>

************************Validar.php*************

<?php


require("connect_db.php");

$username=$_POST['mail'];
$pass=$_POST['pass'];



$sql2=mysql_query("SELECT * FROM login WHERE email='$username'");
if($f2=mysql_fetch_array($sql2)){
if($pass==$f2['pasadmin']){
echo '<script>alert("BIENVENIDO ADMINISTRADOR")</script> ';

echo "<script>location.href='admin.php'</script>";

}
}




$sql=mysql_query("SELECT * FROM login WHERE email='$username'");
if($f=mysql_fetch_array($sql)){
if($pass==$f['password']){
header("Location: index2.php");
}else{
echo '<script>alert("CONTRASEÑA INCORRECTA")</script> ';

echo "<script>location.href='index.php'</script>";
}
}else{

echo '<script>alert("ESTE USUARIO NO EXISTE, PORFAVOR REGISTRESE PARA PODER INGRESAR")</script> ';

echo "<script>location.href='index.php'</script>";

}






?>

*********************Registro*******************+
<?php

$realname=$_POST['realname'];
$mail=$_POST['nick'];
$pass= $_POST['pass'];
$rpass=$_POST['rpass'];

require("connect_db.php");
$checkemail=mysql_query("SELECT * FROM login WHERE email='$mail'");
$check_mail=mysql_num_rows($checkemail);
if($pass==$rpass){
if($check_mail>0){
echo ' <script language="javascript">alert("Atencion, ya existe el mail designado para un usuario, verifique sus datos");</script> ';
}else{

//require("connect_db.php");
mysql_query("INSERT INTO login VALUES('','$realname','$pass','$mail','')");
//echo 'Se ha registrado con exito';
echo ' <script language="javascript">alert("Usuario registrado con éxito");</script> ';
mysql_close($link);
}

}else{
echo 'Las contraseñas son incorrectas';
}


?>

*******Conexión que quiero eliminar y adaptar a la actual*********

<?php
$link =mysql_connect("localhost","root","");
if($link){
mysql_select_db("basededatos",$link);
}
?>




Espero su gran ayuda amigos(As)