ch4rlie Posted November 24, 2014 Share Posted November 24, 2014 I am creating a forgotten password button, it works but it just doesn't send me an email containing the reset link. Here's the code for the email part: <?php require("../config.php"); if($_GET['code']) { $get_username = $_GET['username']; $get_code = $_GET['code']; $query = mysql_query("SELECT * FROM users WHERE username='$get_username'"); while($row = mysql_fetch_assoc($query)) { $db_code = $row['passreset']; $db_username = $row['username']; } if($get_username == $db_username && $get_code == $db_code) { echo " <form action='pass_reset_complete.php?code=$get_code' method='POST'> Enter a new password<br><input type='password' name='newpass'><br> Re-enter your password<br><input type='password' name='newpass1'><p> <input type='hidden' name='username' value='$db_username'> <input type='submit' value='Update Password!'> </form> "; } } if(!$_GET['code']) { echo " <form action='forgot_pass.php' method='POST'> Enter your username<br><input type='text' name='username'><p> Enter your email<br><input type='text' name='email'><p> <input type='submit' value='Submit' name='submit'> </form> "; if(isset($_POST['submit'])) { $username = $_POST['username']; $email = $_POST['email']; $query = mysql_query("SELECT * FROM users WHERE username='$username'"); $numrow = mysql_num_rows($query); if($numrow!=0) { while($row = mysql_fetch_assoc($query)) { $db_email = $row['email']; } if($email == $db_email) { $code = rand(10000,1000000); $to = $db_email; $subject = "Password Reset"; $body = " This is an automated email. Please DO NOT reply to this email. Click the link below or paste it into your browser http:/www.***REMOVED***.com/second/forgot_pass.php?code=$code&username=$username "; mysql_query("UPDATE users SET passreset='$code' WHERE username='$username'"); mail($to,$subject,$body); echo "Check Your Email"; } else { echo "Email is incorrect"; } } else { echo "That username doesnt exist"; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/292683-not-sending-me-email/ Share on other sites More sharing options...
ginerjm Posted November 24, 2014 Share Posted November 24, 2014 What does your script do? Where does it go wrong? Try putting in some messages to help you see the path it is taking. Quote Link to comment https://forums.phpfreaks.com/topic/292683-not-sending-me-email/#findComment-1497546 Share on other sites More sharing options...
ch4rlie Posted November 24, 2014 Author Share Posted November 24, 2014 What does your script do? Where does it go wrong? Try putting in some messages to help you see the path it is taking. Well I tried putting in messages but they dont work -.- Quote Link to comment https://forums.phpfreaks.com/topic/292683-not-sending-me-email/#findComment-1497549 Share on other sites More sharing options...
ginerjm Posted November 24, 2014 Share Posted November 24, 2014 (edited) Why don't you show us that then instead of just saying it. And what exactly does "do not work" imply? Do you have error checking turned on as noted in my signature? Edited November 24, 2014 by ginerjm Quote Link to comment https://forums.phpfreaks.com/topic/292683-not-sending-me-email/#findComment-1497556 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.