Convertir de mysql a mysqli o PDO
Publicado por Erick (1 intervención) el 16/09/2017 00:37:42
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
$cedula=$_POST["cedula"];
$nombre=$_POST["nombre"];
$apellido=$_POST["apellido"];
$telefono=$_POST["tel"];
$sexo=$_POST["sexo"];
$dir=$_POST["dir"];
$email=$_POST["correo"];
$estado=$_POST["estado"];
$user=$_POST["usuario"];
$password=$_POST["pass"];
$password2=$_POST["pass2"];
if ($password2 == $password){
echo"<div align='center'><h1><strong>CONTRASENA VALIDA</strong></h1></div>";
}
else{
echo"<h1>ERROR CONTRASENA NO COINCIDE</h1>";}
$conexion=mysql_connect("localhost","root","");
mysql_select_db("empresa1",$conexion);
$instruccion="INSERT INTO usuarios (cedula, nombre, apellido, telefono, sexo, dir, email, estado, user, pass ) VALUES ('$cedula', '$nombre', '$apellido', '$telefono', '$sexo', '$dir', '$email', '$estado', '$user', '$password')";
$consulta2=mysql_query($instruccion,$conexion)or die("ERROR CREANDO USUARIO");
$consulta=mysql_query("SELECT * FROM usuarios WHERE user='$user' and pass='$password'",$conexion)or die(mysql_error()."ERROR CONSULTANDO USUARIO");
$totalregistro=mysql_num_rows($consulta);
if ($totalregistro > 0){
$row_table=mysql_fetch_array($consulta);
echo "<div align='center'><strong><H1> BIENVENIDO</H1> </strong></div>";
echo "<br><br><br>";
echo"<div align='center'><TABLE BORDER='3' ALIGN='CENTER' WIDTH='400' height='500'>";
echo"<TR><TH COLSPAN='2'><h1>CONSULTA DE USUARIOS</h1></TH></TR>";
echo"<TR><TD><strong>CEDULA:</strong></TD><TD><h3>";
echo $row_table['cedula'];
echo"</h3></td></TR><br>";
echo"<TR><TD><strong>NOMBRE:</strong></td><td><h3>";
echo $row_table['nombre'];
echo"</h3></td></TR><br>";
echo"<TR><TD><strong>APELLIDO:</strong></td><td><h3>";
echo $row_table['apellido'];
echo"</h3></td><TR><br>";
echo"<TR><TD><strong>TELEFONO:</strong></td><td><h3>";
echo $row_table['telefono'];
echo"</h3></td></tr><br>";
echo"<TR><TD><strong>SEXO:</strong></td><td><h3>";
echo $row_table['sexo'];
echo"</h3></td></tr></br>";
echo"<TR><TD><strong>DIRECCION:</strong></td><td><h3>";
echo $row_table['dir'];
echo"</h3></td></tr><br>";
echo"<TR><TD><strong>E-MAIL:</strong></td><td><h3>";
echo $row_table['email'];
echo"</h3></td></tr><br>";
echo"<TR><TD><strong>ESTADO CIVIL:</strong></td><td><h3>";
echo $row_table['estado'];
echo"</h3></td></tr><br>";
echo"<TR><TD><strong>USUARIO:</strong></td><td><h3>";
echo $row_table['user'];
echo"</h3></td></tr><br>";
}
else {
echo"USUARIO NO REGISTRADO";}
echo"</div>";
?>
Por favor necesito este código, pero solo funciona en versiones viejas en PHP , agradecería la ayuda de alguien para migrarlo a la nueva versión. GRACIAS
Valora esta pregunta


0