Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please change this code from mysql to mysqli. Thank you f(isset($_POST[\'loger\'

ID: 3714840 • Letter: P

Question

Please change this code from mysql to mysqli. Thank you

f(isset($_POST['loger']))
{
$uid = mysql_real_escape_string($_POST['uid']);
$pwd = mysql_real_escape_string($_POST['pwd']);
$result = mysql_query("SELECT * FROM user WHERE eid='$uid' AND pwd='$pwd'");

if($row = mysql_fetch_array($result))
{
$_SESSION['stduid2']=$row['eid'];//stores userid session
$_SESSION['stdpwd2']=$row['pwd'];//stores password session
header('location:dashboard.php');
}
else
{
echo '<script type="text/javascript">alert("Invalid Username or Password!");</script>';
}
}
?>
</center>

Explanation / Answer

Answer:

following the conversion of code mysql into mysqli

here no need more conversion simply just you convert mysql method in mysqli.

if any doubt with this conversion comment in comment box and don't forget upvote

f(isset($_POST['loger']))
{
$uid = mysqli_real_escape_string($_POST['uid']);
$pwd = mysqli_real_escape_string($_POST['pwd']);
$result = mysqli_query("SELECT * FROM user WHERE eid='$uid' AND pwd='$pwd'");

if($row = mysqli_fetch_array($result))
{
$_SESSION['stduid2']=$row['eid'];//stores userid session
$_SESSION['stdpwd2']=$row['pwd'];//stores password session
header('location:dashboard.php');
}
else

{
echo '<script type="text/javascript">alert("Invalid Username or Password!");</script>';
}
}
?>
</center>