PHP - convertir a mysqli o pdo

 
Vista:

convertir a mysqli o pdo

Publicado por josele (1 intervención) el 10/08/2020 12:37:56
Hola, necesito convertir este archivo desactualizado a mysqli o pdo. gracias


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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<?php
header("Access-Control-Allow-Origin: *");
include "db.php";
//Create New Account
if(isset($_POST['signup']))
{
	$fullname=mysql_real_escape_string(htmlspecialchars(trim($_POST['fullname'])));
	$email=mysql_real_escape_string(htmlspecialchars(trim($_POST['email'])));
	$password=mysql_real_escape_string(htmlspecialchars(trim($_POST['password'])));
	$login=mysql_num_rows(mysql_query("select * from `users` where `email`='$email'"));
	if($login!=0)
	{
		echo false;
	}
	else
	{
		$date=date("d-m-y h:i:s");
		$q=mysql_query("insert into `users` (`reg_date`,`fullname`,`username`,`email`,`password`) values ('$date','$fullname','$email','$email','$password')");
		if($q)
		{
			echo true;
		}
		else
		{
			echo false;
		}
	}
	echo mysql_error();
}
 
//Login
if(isset($_POST['login']))
{
	$email=mysql_real_escape_string(htmlspecialchars(trim($_POST['email'])));
	$password=mysql_real_escape_string(htmlspecialchars(trim($_POST['password'])));
	$login=mysql_num_rows(mysql_query("select * from `users` where `email`='$email' and `password`='$password'"));
	if($login!=0)
		{ echo true; }
	else{ echo false; }
}
 
//Change Password
if(isset($_POST['change_password']))
{
	$email=mysql_real_escape_string(htmlspecialchars(trim($_POST['email'])));
	$old_password=mysql_real_escape_string(htmlspecialchars(trim($_POST['old_password'])));
	$new_password=mysql_real_escape_string(htmlspecialchars(trim($_POST['new_password'])));
	$check=mysql_num_rows(mysql_query("select * from `users` where `email`='$email' and `password`='$old_password'"));
	if($check!=0)
	{
		mysql_query("update `users` set `password`='$new_password' where `email`='$email'");
		echo true;
	}
	else
	{
		echo false;
	}
}
 
// Forget Password
if(isset($_POST['forget_password']))
{
	$email=mysql_real_escape_string(htmlspecialchars(trim($_POST['email'])));
	$q=mysql_query("select * from `users` where `email`='$email'");
	$check=mysql_num_rows($q);
	if($check!=0)
	{
		echo true;
		$data=mysql_fetch_array($q);
		$string="Hey,".$data['fullname'].", Tu password es".$data['password'];
		mail($email, "Tu Password", $string);
	}
	else
	{
		echo false;
	}
}
 
?>
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder