Noskiw Posted June 4, 2010 Share Posted June 4, 2010 Can anyone make it so that this successfully sends email from a localhost server. <?php $submit = $_POST['submit']; $id = $_GET['id']; $firstname = strip_tags($_POST['firstname']); $lastname = strip_tags($_POST['lastname']); $email = addslashes(strip_tags($_POST['email'])); $username = addslashes(strip_tags($_POST['username'])); $password = addslashes(strip_tags($_POST['password'])); $verifypassword = strip_tags($_POST['verifypassword']); $date = date("Y-m-d"); if($submit){ if($firstname&&$lastname&&$email&&$username&&$password&&$verifypassword&&$date){ if($password == $verifypassword){ if(strlen($firstname)>25||strlen($lastname)>25||strlen($username)>25){ echo "<b>Maximum limit</b> for the First, Last and username's are 25 characters"; }else{ if(strlen($password)>25||strlen($password)<6){ echo "Password must be <b>between</b> 6 and 25 characters!"; }else{ $password = md5($password); $verifypassword = md5($verifypassword); $random = rand(23456789,98765432); $sql = "INSERT INTO users VALUES('','$firstname','$lastname','$email','$random','0','$username','$password','$date')"; $res = mysql_query($sql) or die(mysql_error()); $lastid = mysql_insert_id(); $to = $email; $subject = "Activate your account!"; $body = " Hello $firstname $lastname,\n\n You need to activate your account with the link below... http://localhost/projects/p_web/index.php?p=activate&id=$lastid&code=$random\n\n Thanks! "; $headers = "From: [email protected]"; mail($to, $subject, $body, $headers); echo "Success! Check your email to activate your account!"; } } } }else{ echo "Passwords <b>Do Not Match</b>!"; } }else{ echo "Please fill in <b>all</b> fields!"; } ?> <form action="index.php?p=reg" method="POST"> <table> <h1>Register</h1> <tr><td>First Name: </td><td><input type="text" name="firstname" value="<?php echo $firstname; ?>" /></td></tr> <tr><td>Last Name: </td><td><input type="text" name="lastname" value="<?php echo $lastname; ?>" /></td></tr> <tr><td>Email: </td><td><input type="text" name="email" value="<?php echo $email; ?>" /></td></tr> <tr><td>Username: </td><td><input type="text" name="username" value="<?php echo $username; ?>" /></td></tr> <tr><td>Password: </td><td><input type="password" name="password" /></td></tr> <tr><td>Verify Password: </td><td><input type="password" name="verifypassword" /></td></tr> <tr><td><input type="submit" name="submit" value="Register" /></tr></td> </table> </form> Because it always says that the email has been sent... Yet it never arrives... -.-' Link to comment https://forums.phpfreaks.com/topic/203920-help-please/ Share on other sites More sharing options...
ohdang888 Posted June 4, 2010 Share Posted June 4, 2010 try changing: $to = $email; to: $to = $_POST['email']; Link to comment https://forums.phpfreaks.com/topic/203920-help-please/#findComment-1068006 Share on other sites More sharing options...
Noskiw Posted June 5, 2010 Author Share Posted June 5, 2010 I have a different problem now -.-' THis is my code now <?php $submit = $_POST['submit']; $id = $_GET['id']; $firstname = strip_tags($_POST['firstname']); $lastname = strip_tags($_POST['lastname']); $email = addslashes(strip_tags($_POST['email'])); $username = addslashes(strip_tags($_POST['username'])); $password = addslashes(strip_tags($_POST['password'])); $verifypassword = strip_tags($_POST['verifypassword']); $date = date("Y-m-d"); if($submit){ if($firstname&&$lastname&&$email&&$username&&$password&&$verifypassword&&$date){ if($password == $verifypassword){ if(strlen($firstname)>25||strlen($lastname)>25||strlen($username)>25){ echo "<b>Maximum limit</b> for the First, Last and username's are 25 characters"; }else{ if(strlen($password)>25||strlen($password)<6){ echo "Password must be <b>between</b> 6 and 25 characters!"; }else{ $password = md5($password); $verifypassword = md5($verifypassword); $random = rand(23456789,98765432); $sql = "INSERT INTO users VALUES('','$firstname','$lastname','$email','$random','0','$username','$password','$date')"; $res = mysql_query($sql) or die(mysql_error()); $lastid = mysql_insert_id(); $to = $_POST['email']; $subject = "Activate your account!"; $body = " Hello $firstname $lastname,\n\n You need to activate your account with the link below... http://localhost/projects/p_web/index.php?p=activate&id=$lastid&code=$random\n\n Thanks! "; $headers = "From: [email protected]"; mail($to, $subject, $body, $headers); echo "Success! Check your email to activate your account!"; } } } }else{ echo "Passwords <b>Do Not Match</b>!"; } }else{ echo "Please fill in <b>all</b> fields!"; } ?> <form action="index.php?p=reg" method="POST"> <table> <h1>Register</h1> <tr><td>First Name: </td><td><input type="text" name="firstname" value="<?php echo $firstname; ?>" /></td></tr> <tr><td>Last Name: </td><td><input type="text" name="lastname" value="<?php echo $lastname; ?>" /></td></tr> <tr><td>Email: </td><td><input type="text" name="email" value="<?php echo $email; ?>" /></td></tr> <tr><td>Username: </td><td><input type="text" name="username" value="<?php echo $username; ?>" /></td></tr> <tr><td>Password: </td><td><input type="password" name="password" /></td></tr> <tr><td>Verify Password: </td><td><input type="password" name="verifypassword" /></td></tr> <tr><td><input type="submit" name="submit" value="Register" /></tr></td> </table> </form> This is my php.ini mail function settings [mail function] ; For Win32 only. SMTP = smtp.googlemail.com smtp_port = 465 ; For Win32 only. ;sendmail_from = [email protected] And this is my error Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\xampp\htdocs\projects\p_web\include\reg.php on line 51 -.-' That is insanely frustrating... Link to comment https://forums.phpfreaks.com/topic/203920-help-please/#findComment-1068169 Share on other sites More sharing options...
Noskiw Posted June 5, 2010 Author Share Posted June 5, 2010 Bump. I still have the problem Link to comment https://forums.phpfreaks.com/topic/203920-help-please/#findComment-1068268 Share on other sites More sharing options...
ohdang888 Posted June 5, 2010 Share Posted June 5, 2010 i think it has to do with your $headers information but i'm not positive Link to comment https://forums.phpfreaks.com/topic/203920-help-please/#findComment-1068337 Share on other sites More sharing options...
Noskiw Posted June 5, 2010 Author Share Posted June 5, 2010 AI just get this error here Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\projects\p_web\include\reg.php on line 49 -.-' It's ridiculous :L Link to comment https://forums.phpfreaks.com/topic/203920-help-please/#findComment-1068345 Share on other sites More sharing options...
Noskiw Posted June 6, 2010 Author Share Posted June 6, 2010 Is anyone going to help me? Because I'm still stuck Link to comment https://forums.phpfreaks.com/topic/203920-help-please/#findComment-1068693 Share on other sites More sharing options...
siva.katir Posted June 6, 2010 Share Posted June 6, 2010 I think your header is wrong: $header = "From: [email protected]\r\n" . "X-Mailer: php"; Also, you should try testing it by removing the header option. If it's still failing your have a bigger issue. Link to comment https://forums.phpfreaks.com/topic/203920-help-please/#findComment-1068718 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.