[ Foro de SQL (y MySQL) ]

convertir a mysql o pdo

10-Aug-2020 12:31
Invitado (josele)
0 Respuestas

Hola, alguien podria ayudarme con este archivo php, necesito convertir de mysql a mysqli o pdo.  Gracias
==============================================================================
<?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;
}
}

?>




Si ya eres usuario del sistema, puedes contestar desde tu cuenta y así ganar prestigio.

Si sólo eres un visitante, puedes optar por...