简体   繁体   中英

SQL Forgot Email PHP Page Giving Error `The multi-part identifier could not be bound. (severity 16) `

I am trying to make a forgot password page using PHP for my website. Basically there is a form on the page that requires an email. The form looks for the email in my staffportal MSSQL table's column email . If the email exists in the table, it will retrieve the data from the password column from that same row. With the retrieved password, it will send an email containing the password to the email from that table row. Right now when I enter a correct email that exists in the staffportal table, it reads these errors:

Warning: mssql_query() [function.mssql-query]: message: The multi-part identifier "kelsey.alon@s.ca" could not be bound. (severity 16) in D:\Hostingd990\html\staffportal\forgotemail.php on line 23

Warning: mssql_query() [function.mssql-query]: Query failed in D:\Hostingd90\html\staffportal\forgotemail.php on line 23

Warning: mssql_num_rows(): supplied argument is not a valid MS SQL-result resource in D:\Hostingd\html\staffportal\forgotemail.php on line 24
Thank you, ! we will get back to you.

Here is my full page code:

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<?php 
$conn=mssql_connect('gdom','Gd','d1!');
mssql_select_db('ar',$conn);
if (isset($_POST['forgotpass'])) {
$conn=mssql_connect('gdcom','GBder','Rd1!');
mssql_select_db('GBd',$conn);
    if (!get_magic_quotes_gpc()) {

        $_POST['email'] = addslashes($_POST['email']);

    }

 $email = $_POST['email'];
$querye = "SELECT password FROM staffportal WHERE email = ".$_POST['email']."";
$check = mssql_query($querye, $conn);
$check2 = mssql_num_rows($check);
echo "".$check2."";
//if the email doesn't exist it gives an error
if ($check2 = 0) {
echo '<script>alert("Sorry, the email '.$email.' is incorrect.");</script>';
} else {

print"<p>Thank you, $fname! we will get back to you.</p>";
print"<p>Today's date is $date.</p>";

$to = "".$email."";
$subject = "Financing for $fname $lname";
$body = " Date: $date \n\n Note: If any fields have been left blank it means the user did not input anything. \n\n First name: $fname \n Last name: $lname \n Company: $cname \n Email: $email \n Phone: $phone \n Fax: $fax \n Address: $address \n City: $city \n Province: $province \n Postal Code: $postal \n Equipment Type: $et \n Amount: $amount\n\n";
$headers = "From: info@gba.ca";
mail($to, $subject, $body, $headers);

}
} else {
?>
<form method="POST" action="<?php $_PHP_SELF ?>">
      Email:<br />
      <input type="text" name="email" id="email"/>
 <br /><br />
      <input type="submit" id="forgotpass" value="Change Password" name="forgotpass"/>
</form>
<?php } ?>
</body>
</html>

Thank you for any help. All help is appreciated.

$querye = "SELECT password FROM staffportal WHERE email = ".$_POST['email']."";

应该

$querye = "SELECT password FROM staffportal WHERE email = '".$_POST['email']."'";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM