ababmxking Posted November 19, 2008 Share Posted November 19, 2008 Ok so I'm trying to make this form but its not working, I know it has something to do with the $body var. And when it does sent it doesn't show a sender e-mail or subject. <? include 'other/db_connect.php'; $lostusername = $_POST['username']; $lostemail = $_POST['email']; if ($_POST['submit'] && empty($_POST['email'])){ $error = "You either didn't enter an email or password. You must enter both for security reasons."; } if ($_POST['submit'] && empty($_POST['username'])){ $error = "You either didn't enter an email or password. You must enter both for security reasons."; } if($_POST['username'] && $_POST['email']){ $lostpassword = mysql_query("SELECT `password` FROM `user` WHERE `username` = '$lostusername' || 'email' = '$lostemail' LIMIT 1") or die(mysql_error()); $num = mysql_num_rows( $lostpassword ); $lostpassword2 = mysql_fetch_object( $lostpassword ); if ( $num == '0' ){ $error = "Sorry but we could not find a match for the info you have entered."; } elseif ( $num == '1' ){ $error = "Your password has been sent!"; $Name = "Racing-Generation"; $email = "[email protected]"; //senders e-mail adress $recipient = $lostemail ; //recipient $mail_body = "Hello $lostusername, we understand it that you have lost your password. well dont worry about it. Here is your password below. Password: $lostpassword2 Thanks, Racing-Generation Please DO NOT reply to this. This e-mail address is not attended to. We have other e-mails for you to contact us. "; //mail body $subject = "Your Password"; //subject $header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields ini_set('sendmail_from', '[email protected]'); mail($recipient, $subject, $mail_body, $header); //mail command } echo"$error"; } ?> <!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=utf-8" /> <title>Racing-Generation - Lost Password</title> <style type="text/css"> <!-- body { background-color:#3f0507; font-family: Verdana; font-size:12px; color:#FFF; } .row1 { font-size: xx-large; font-family: Georgia, "Times New Roman", Times, serif; font-weight: bold; color: #FFF; } #form1 table { text-align: center; } #form1 table { text-align: left; } --> </style> </head> <body bgcolor="#3f0507"> <form action="" method="post"> <table width="70%" border="0" align="center" cellpadding="0" cellspacing="5"> <tr> <td colspan="2" class="row1" align="center">Racing-Generation</td> </tr> <tr> <td colspan="2" ><hr align="center" width="80%" noshade="noshade" color="#FFFFFF" /> <center>If you have lost your password then please enter one of the below. If you do not know your username then we are sorry but you will have to re-register and have an admin find your old account.</center></td> </tr> <tr> <td align="right">E-mail Address:</td> <td><input type="text" name="email" ></td> </tr> <tr> <td width="40%" align="right">Username:</td> <td><input type="text" name="username" ></td> </tr> <tr> <td width="40%"> </td> <td> <input type="submit" name="button" value="Submit" > </td> </tr> <tr> <td colspan="2" align="center"></td> </tr> </table> <br /> </body> </html> there is the whole code. It has been awhile since I've done any kind of coding so i know there are some mess ups. Link to comment https://forums.phpfreaks.com/topic/133290-mail-function-help/ Share on other sites More sharing options...
redarrow Posted November 19, 2008 Share Posted November 19, 2008 Put this together for you...... All you need to do is name the page mail.php add your smtp port, and ip, if needed and your email address........... goto mail.php test the code...... try it see if it work's if so it becouse you not useing the correct headers...... redisign the code to ur needs...... <?php ini_set("SMTP", "your ip address"); // if needed........ ini_set("smtp_port", "25"); // port your sending smtp from........... $FullName='redarrow'; $email='[email protected]'; $Message='hi i am redarrow love php'; $FullName = Trim(stripslashes($_POST['full_name'])); $Email = Trim(stripslashes($_POST['email'])); $Message = Trim(stripslashes($_POST['message'])); $to = 'your email address'; // set the email address.......... $subject = 'Testing mail!'; $mes = "Hello; \n\n You have recieved an email from "; $mes .= "you website's contact form. The message is below for your convenience. \n\n ****************************** \nFull Name: "; $mes .= $full_name; $mes .= "\n"; $mes .= "Email: "; $mes .= $Email; $mes .= "\n"; $mes .= "Message: "; $mes .= $Message; $mes .= "\n ****************************** \n\n This Is An Automatically Generated Message, Do Not Repond!"; $message = $mes; $headers = 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // Send if(mail($to, $subject, $message, $headers)){ echo " MAIL WAS SENT TO $email!"; } ?> Link to comment https://forums.phpfreaks.com/topic/133290-mail-function-help/#findComment-693264 Share on other sites More sharing options...
redarrow Posted November 19, 2008 Share Posted November 19, 2008 EDITED............. Here a full working product fully tested............ <?php //ini_set("SMTP", "your ip address"); // if needed........ //ini_set("smtp_port", "25"); // port your sending smtp from........... $Full_Name='redarrow'; $Email='[email protected]'; $Messages='hi i am redarrow love php'; $to = '[email protected]'; // set the email address.......... $subject = 'Testing mail!'; $mes = "Hello; $Full_Name <br><br> You have recieved an email from $Email <br><br>"; $mes .= "This message below is for your convenience. <br><br> ****************************** <br><br> Full Name: "; $mes .= $Full_Name; $mes .= "<br><br>"; $mes .= "Email: "; $mes .= $Email; $mes .= "<br><br>"; $mes .= "Message: "; $mes .= $Messages; $mes .= "<br><br>****************************** <br><br>This Is An Automatically Generated Message, Do Not Repond!"; $message = $mes; $headers = 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // Send if(mail($to, $subject, $message, $headers)){ echo " MAIL WAS SENT TO $to!"; } ?> Link to comment https://forums.phpfreaks.com/topic/133290-mail-function-help/#findComment-693272 Share on other sites More sharing options...
ababmxking Posted November 20, 2008 Author Share Posted November 20, 2008 Thanks, but i still cant figure out how to get the sender email to show up in the email inbox Link to comment https://forums.phpfreaks.com/topic/133290-mail-function-help/#findComment-694091 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.