Irresistable Posted November 12, 2009 Share Posted November 12, 2009 I have this contact form. - What it's suppose to do, is have two fields, message and subject. The user has to be logged in to submit the form, and with the session, it gets the users "username" (So admin can identify the user) and.. it gets the users email from the database. It does get the email address, as i checked it with the body, and it comes up correct. The code below, when I recieve the email it comes up as..: Time From Subject Size 13:59:37 To: [email protected] Reporting A Problem 655 It should display the from address.. which in my case.. when I submit the form, it is admin. It shouldn't contain the "To:" though. Here is my PHP code <?php session_start(); include("config.php"); if(isset($_POST['submit'])) { $username = ucwords($_SESSION['s_username']); $query = mysql_query("SELECT Email FROM Users WHERE Username = '$username' LIMIT 1") or die(mysql_error()); $user = mysql_fetch_array($query); $to = "[email protected]"; $subject = $_POST['subject']; $name = $username; $email = $user['Email']; $message = $_POST['message']; $body = "$message\n\n $name"; echo "Data has been submitted to $to!"; mail($to, $subject, $body, "From: $name <$email>\r\n"); } else { echo "<strong>Error, something has gone wrong, please try again later.</strong>"; } ?> Link to comment https://forums.phpfreaks.com/topic/181288-solved-contact-form-how-do-i-set-the-from/ Share on other sites More sharing options...
Irresistable Posted November 12, 2009 Author Share Posted November 12, 2009 Wait sorry for the post, it works.. I got someone else to test it, its because my registered email is the same as the one it sends to. Link to comment https://forums.phpfreaks.com/topic/181288-solved-contact-form-how-do-i-set-the-from/#findComment-956365 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.