dannybeales Posted July 14, 2008 Share Posted July 14, 2008 hey people, i have a problem on my game that my lost password script refuses to send the activation email here is the code: <?php include_once("config.php"); include_once("connect.php"); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Forgot Password.</title> <link href="style.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="800" border="0" align="center" cellspacing="0"> <tr> <td><table border="0" align="center" cellspacing="2"> <tr> <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='index.php'"><a href="index.php" onFocus="if(this.blur)this.blur()">Login.</a></td> <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='register.php'"><a href="register.php" onFocus="if(this.blur)this.blur()">Register.</a></td> <td class="off" onmouseover="this.className='on'" onmouseout="this.className='off'" onclick="location.href='tos.php'"> <a href="tos.php" onFocus="if(this.blur)this.blur()">Terms of service.</a></td> </tr> </table></td> </tr> <tr> <td align="center" valign="middle"><form method="post"> <br /> <table width="350" border="0" align="center" cellspacing="0"> <tr> <td colspan="2" align="center"> <?php include_once("config.php"); include_once("connect.php"); if(isset($_POST['Submit'])){ $sql = "SELECT status FROM sitestats WHERE id='1'"; $query = mysql_query($sql) or die(mysql_error()); $row = mysql_fetch_object($query); $page_status = htmlspecialchars($row->status); $page_status_array = explode("-", $page_status); if(!empty($page_status_array[33])){ echo htmlspecialchars(stripslashes($page_status_array[33])); }else{ $nsql = "SELECT mail,name FROM login WHERE name='".mysql_real_escape_string($_POST['name'])."'"; $query = mysql_query($nsql) or die(mysql_error()); $row = mysql_fetch_object($query); $name = htmlspecialchars($row->name); $mail = htmlspecialchars($row->mail); if((empty($_POST['name'])) or (empty($_POST['mail']))){ echo "You left one or more fields empty."; }else{ if(empty($name)){ echo "Invalid information."; }else{ if($_POST['mail'] != $mail){ echo "Invalid information."; }else{ for ($i = 0; $i < 10; $i++) { $pnum[$i] = rand(0,9); } $new_pass = "$pnum[0]$pnum[1]$pnum[2]$pnum[3]$pnum[4]$pnum[5]$pnum[6]$pnum[7]$pnum[8]$pnum[9]"; $bericht = "Your password has been Reset. Please change it to your own ASAP.\n\n"; $bericht .= "Password: ".$new_pass."\n"; $bericht .= "Special Execution Password: ".$new_pass."\n"; $mail = mail($mail,"Welcome to ".$site_name,$bericht,"From: ".$site_name." <".$site_mail.">"); $new_pass = md5($new_pass); $result = mysql_query("UPDATE login SET password='".$new_pass."', login_count='0' WHERE name='" .mysql_real_escape_string($name). "'") or die(mysql_error()); echo ""Password: ".$new_pass."\n";"; }// if invalid email. }// if invalid name }// if empty field. }// if dissabled. }// if isset. ?> </td> </tr> <tr> <td width="75" align="left">Username:</td> <td width="275" align="center"><input name="name" type="text" class="entryfield" id="name" style='width: 95%;' size="20"/></td> </tr> <tr> <td width="75" align="left">Email:</td> <td width="275" align="center"><input name="mail" type="text" class="entryfield" id="mail" style='width: 95%;'/></td> </tr> <tr> <td colspan="2"><table width="100" border="0" align="right" cellspacing="0"> <tr> <td align="center"><input name="Submit" type="submit" class="button" value="Submit"onfocus="if(this.blur)this.blur()" /></td> </tr> </table></td> </tr> </table> </form></td> </tr> </table> </body> </html> thanks all Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/ Share on other sites More sharing options...
JasonLewis Posted July 14, 2008 Share Posted July 14, 2008 Refuses? Any errors? Try echoing out variables, or die() the variables at certain stages to track things. Usually problems like this can be solved by taking some basic error tracking steps to try and trace it. Just work through your script to find out where it isn't working. Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-589481 Share on other sites More sharing options...
dannybeales Posted July 14, 2008 Author Share Posted July 14, 2008 well it does work echo "Password: ".$new_pass."n"; as that tells you your new password but that isnt very secure so i wanted it to send a mail, but i just doesnt wat to. it changes your password but you do not get any mail. can you see my problem? Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-589487 Share on other sites More sharing options...
DeanWhitehouse Posted July 14, 2008 Share Posted July 14, 2008 this line won't work $mail = mail($mail,"Welcome to ".$site_name,$bericht,"From: ".$site_name." <".$site_mail.">"); you have it sending the email to mail($mail,"Welcome to ".$site_name,$bericht,"From: ".$site_name." <".$site_mail.">"); and why are you putting it in a variable anyway? Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-589508 Share on other sites More sharing options...
JasonLewis Posted July 14, 2008 Share Posted July 14, 2008 Putting it in a variable you can test if the mail was sent, as mail() returns true on success or false if it failed. Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-589524 Share on other sites More sharing options...
DeanWhitehouse Posted July 14, 2008 Share Posted July 14, 2008 or you can just do if(mail()) { echo "mailed"; } else { echo "not"; } Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-589608 Share on other sites More sharing options...
JasonLewis Posted July 15, 2008 Share Posted July 15, 2008 or you can just do if(mail()) { echo "mailed"; } else { echo "not"; } Of course, but there is nothing wrong with storing it in a variable. Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-590231 Share on other sites More sharing options...
samshel Posted July 15, 2008 Share Posted July 15, 2008 the problem is the variable or mail not being sent? Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-590236 Share on other sites More sharing options...
JasonLewis Posted July 15, 2008 Share Posted July 15, 2008 The mail isn't sent from his server for some reason. mail() is returning true but nothing is received. Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-590239 Share on other sites More sharing options...
samshel Posted July 15, 2008 Share Posted July 15, 2008 Sorry a stupid(but primary) debug technique, but did you try if hard coded mail function works mail("samirshelar@hotmail.com", "Test Mail", "Mail Body..."); Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-590244 Share on other sites More sharing options...
JasonLewis Posted July 15, 2008 Share Posted July 15, 2008 Well I got him to try that on a blank script, sending it to himself and me... Nothing. Didn't work. No errors. Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-590245 Share on other sites More sharing options...
DeanWhitehouse Posted July 15, 2008 Share Posted July 15, 2008 no one's asked if he has mailing enabled on his host. Do you? Quote Link to comment https://forums.phpfreaks.com/topic/114643-forgotten-passwrod-script/#findComment-590249 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.