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 [nobody@wilde@uknoc.co.uk]” (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

Tony

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:-

<?php
/* Set e-mail recipient */
$myemail = “sales@abc.uk.com”;
$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

Enquiry:
$enquiry

How did you find us:
$how_find

End of message
";

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

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

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

function show_error($myError)
{
?>
<html>
<body>

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

&lt;/body&gt;
&lt;/html&gt;

<?php
exit();
}
?>

Top of Microsoft Outlook email header

Southern Sales Enquiry
Nobody [nobody@wilde.uknoc.co.uk] {this line here}
Sent: Mon 07/02/2011 12:24
To: sales@abc.uk.com

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

Is this enough info if not what else do you need

Tony

http://fr2.php.net/manual/en/function.mail.php

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,

Tony

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.

Guido

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

Tony

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

$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\\r\
";

Guido

Cheers :):slight_smile:

Tony

Guido

you were spot on

Problem Solved

Thank You