Help with Contact Us Form

Hi All

I have just launched my first website designed and written by me for my small business, written in xhtml & css with a php contact us script
It might not be that great! but its my intoduction into web design,

for now all seems to work except for this point

when I receive the submitted form from my contact page -
the email “From display name” with “email address” in brackets beside it shows as
“Nobody []” (Hosting Server default address)

instead, how do I get this to show that this is from the sender.

I know this bit is missing in my php code, not sure how to code this

As you can see I am somewhat green at php:blush:

Thanks for any help in advance


If you could post the code and perhaps an example of entered form data and the current result, and what your desired outcome is, we would be far more able to help you.

Hi again
php code below:-

/* Set e-mail recipient */
$myemail = “”;
$subject = “Southern Sales Enquiry”;

/* Check all form inputs using check_input function */
$yourname = check_input($_POST[‘yourname’], “Enter your name”);
$company = check_input($_POST[‘company’], “Enter your company name”);
$phone = check_input($_POST[‘phone’], “Enter your company telephone number”);
$extension = check_input($_POST[‘extension’]);
$email = check_input($_POST[‘email’]);
$website = check_input($_POST[‘website’]);
$how_find = check_input($_POST[‘how’]);
$enquiry = check_input($_POST[‘enquiry’], “Please give a breif description of your enquiry”);

if (strtolower($_POST[‘code’]) != ‘southerncode’) {die(‘Wrong access code’);}

/* If e-mail is not valid show error message */
if (!preg_match(“/([\w\-]+\@[\w\-]+\.[\w\-]+)/”, $email))
show_error(“Please enter a valid E-mail address”);

/* Let’s prepare the message for the e-mail */
$message = "Hello!

Your contact form has been submitted by:

Name: $yourname
Company: $company
Phone: $phone
Extension: $extension
E-mail: $email
Website: $website


How did you find us:

End of message

/* Send the message using mail() function */
mail($myemail, $subject, $message);

/* Redirect visitor to the thank you page */
header(‘Location: thanks.htm’);

/* Functions we used */
function check_input($data, $problem=‘’)
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
return $data;

function show_error($myError)

&lt;b&gt;Please correct the following error:&lt;/b&gt;&lt;br /&gt;
&lt;?php echo $myError; ?&gt;



Top of Microsoft Outlook email header

Southern Sales Enquiry
Nobody [] {this line here}
Sent: Mon 07/02/2011 12:24

This line here is the problem, needs to show :- From details/email address

Is this enough info if not what else do you need


See example #4

Ahhh!!! my mistake,

this is when I receive the email from my website contact page (not send it.)

or am I missing something,


The code you posted is where the email is made and sent.
I thought your question was how to get the email header to have the clients email address in the ‘from’.
Example #4 of the php manual shows how to do that.


Thank you for your reply

Looks like I’ve got a lot more learning to do,
will go over the code, experiment with it and see how it functions :confused:

Thank you again


Don’t want to confuse you too much :smiley:
The important part for you is this:

$headers .= 'From: Birthday Reminder <>' . "\\r\


Cheers :):slight_smile:



you were spot on

Problem Solved

Thank You