Jump to content

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 <applications@virtualamerican.org>\r\n";
$headers .= "Reply-To: Virtual American Airlines <applications@virtualamerican.org>\r\n";
$headers .= "Return-Path: Virtual American Airlines <applications@virtualamerican.org>\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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.