Jump to content

Recommended Posts

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: admin@developers-community.com  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 = "admin@developers-community.com";
$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>";
}
?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.