lordbob Posted January 17, 2007 Share Posted January 17, 2007 I am trying to make a 'forgot password' tool on my website, basically the person fills out an HTML form which is then sent to a php file called forgot.PHP(they send $Email to the PHP file via GET method)this is my code for forgot.php:[code]<?//-------------------------------------------Connect to Database://set the variables as required$dbhost = "fdb1.awardspace.com";$dbuser = "rocketeermus_db1";$dbpass = "******";$dbname = "rocketeermus_db1";//do not edit this, it connects the script$members = mysql_connect($dbhost,$dbuser,$dbpass);//line10mysql_select_db($dbname) or die(mysql_error());//------------------------------------------------------------------Send Mail Bit $sql="SELECT Password, Username FROM Members WHERE Email='$Email'";$result=mysql_query($sql);//line20$count=mysql_num_rows($result); if($count==1){$rows=mysql_fetch_array($result);// keep password in $your_password$your_password=$rows['Password'];$your_username=$rows['Username'];$subject = "Password Request";//line30$body = "Your password request has been processed!\n\nUsername: $your_username\nPassword: $your_password";if (mail($Email, $subject, $body)) { echo"<p>Message successfully sent!</p>"; } else { echo"<p>Message delivery failed...</p>"; }}else{echo"<p>Your email address was not found on our database, you must register first!</p>";}?>[/code]does anyone know why it isnt sending the email?thanks ~ Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 $Email is never defined.You really need to stop posting your database login info. This is the second time from you, and third or fourth today Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 yer woops sorry about that :P Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 $email is sent from forgot.html (the form page) Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 You should turn global variables off and do $email = $_GET['email'];Is it email or Email? Caps matter.Do you get the error message or just nothing? Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 its $Emailhow do i turn off global thingy?and will that effect other php files on my website that send variables like that? Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 there is no error message, it says "email sent" but i dont get it :-\ Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 Did you check your junkmail? What email service are you using? Try other addresses on other servers. Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 yeh im using hotmail, i checked junk...nothing there Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 if it doesnt work for hotmail then im pretty screwed because all the people who are registering use hotmail :-\ Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 You need to set some additional headers in order for hotmail to work I think. Checkout the mail() function in the manual. Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 yer iv browsed google and everyone seems to be having this problem when sending to hotmail/gmail/yahoo etc. Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 does anyone know a way around this problem?at the moment the only stuff i have found is either wrong or i cant understand it!HELP ME!!!!! :-\ Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 17, 2007 Share Posted January 17, 2007 HELP YOURSELF.You need to use the additional headers as outlined here. http://us3.php.net/manual/en/function.mail.phpSpecifically MIME type and these:$headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion();Read the documentation and TRY to understand. Quote Link to comment Share on other sites More sharing options...
lordbob Posted January 17, 2007 Author Share Posted January 17, 2007 iv gone through all of that stuff, the mime stuff and the other extra headers, nothing works :( Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 18, 2007 Share Posted January 18, 2007 Well we can't help you then. If you want to post all the relevant files, someone might be willing to look through them, or you could post on the freelancers forum for more advanced help. Quote Link to comment Share on other sites More sharing options...
anatak Posted January 18, 2007 Share Posted January 18, 2007 are your ini settings correct ?this works for me (with my details)[code]$subject = 'title string';$body = 'email string you want to send';$email = 'info@example.com';//working mailbox from your domain$header = "From: $email";ini_set("SMTP", "ASK YOUR PROVIDER"); //use for online versionini_set("smtp_port", "25");mail($to, $subject, $body, $header);[/code] Quote Link to comment 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.