Jump to content

Code not working


dudejma

Recommended Posts

Why's this code not working? It doesn't give any errors, it just goes to the forgotPass1.php and doesn't do anything.

 

<?php

require 'include/sql.php';

if (isset($_POST['submit'])) {
$pilotid = $_POST['pilotid'];
$random = md5(uniqid(rand()));
$sql = "SELECT * FROM users WHERE pilotID='$pilotid'";
$result = mysql_query($sql)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());
while ($row = mysql_fetch_array($result)) {
$to = $row['email'];
$message = "This email was sent because someone recently requested for a password reset for your account. If this was not you, please disregard this email. If it was you, click <a href=\"forgotPass2.php?" . $random . "\">here</a> to reset your password.";
$subject = "Password Reset";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "From: Virtual American Airlines <[email protected]>\r\n";
$headers .= "Reply-To: Virtual American Airlines <[email protected]>\r\n";
$headers .= "Return-Path: Virtual American Airlines <[email protected]>\r\n";
$headers .= "X-Mailer: PHP". phpversion() ."\r\n";
$sql2 = "INSERT INTO temp_pass (pilotID, random) VALUES ('$pilotid', '$random')";
$result2 = mysql_query($sql2)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());
mail($to,$subject,$message,$headers)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());
$errors = "We have sent you your password. Please check your email.";
header("Location: login.php");
}
}
?>

 

Thanks!

Link to comment
https://forums.phpfreaks.com/topic/243424-code-not-working/
Share on other sites

mail($to,$subject,$message,$headers)
or die("An error has occured. Please contact the webmaster with the following error: " . mysql_error());

 

the mail() function would not report a mysql_error...you can do something like this instead..

 

if(!mail($to,$subject,$message,$headers)){
      trigger_error("An error has occurred in the mailing process",E_USER_ERROR);
}

 

also, I do not see a forgotPass1.php in the code you provided

Link to comment
https://forums.phpfreaks.com/topic/243424-code-not-working/#findComment-1250006
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.