Newbie needs help with form to email
Posted: Tue Jun 30, 2009 3:44 pm
Hi everyone.
I have just started with php but need help!
I have a form on my site that I want to email me when completed but I am having problems getting the email to work?
When submitted the form calls in a file called contact.php which I have copied from a php book. The coding is below.
The form url is http://www.mdcomputertraining.co.uk/form.htm which seems to work as expected but no email actually gets delivered back to me?
Can someone please have a look - i am sure the code just needs tweaking but I dont know where to begin??
Grateful for any guidance.
Cheers
Mark
<?
if (($_POST[name] == "") ||
($_POST[email] == "") ||
($_POST[telnumber] == "") ||
($_POST[message] == "")) {
header ("Location: http://www.mdcomputertraining.co.uk/form.htm");
exit;
}
$msg .= "email sent from www site\n";
$msg .= "senders's name:\t$_POST[name]\n";
$msg .= "senders's email:\t$_POST[email]\n";
$msg .= "senders's tel number:\t$_POST[telnumber]\n";
$msg .= "message:\t$_POST[message]\n";
$to = 'md@mdavies7.plus.com';
$subject = "Web site message";
$mailheaders = "From: My Web site <mdcomputertraining.co.uk>\n";
$mailheaders .= "Reply-To: $_POST[email]\n";
mail ($to, $subject, $msg, $mailheaders);
?>
<html>
<head>
<title>Simple feedback form sent</title>
</head>
<body>
<H1>The following e-mail has been sent</H1>
<p><strong>Name:</strong><br>
<? echo "$_POST[name]"; ?>
<p><strong>Email:</strong><br>
<? echo "$_POST[email]"; ?>
<p><strong>Tel Number:</strong><br>
<? echo "$_POST[telnumber]"; ?>
<p><strong>Message:</strong><br>
<? echo "$_POST[message]"; ?>
</body>
</html>
I have just started with php but need help!
I have a form on my site that I want to email me when completed but I am having problems getting the email to work?
When submitted the form calls in a file called contact.php which I have copied from a php book. The coding is below.
The form url is http://www.mdcomputertraining.co.uk/form.htm which seems to work as expected but no email actually gets delivered back to me?
Can someone please have a look - i am sure the code just needs tweaking but I dont know where to begin??
Grateful for any guidance.
Cheers
Mark
<?
if (($_POST[name] == "") ||
($_POST[email] == "") ||
($_POST[telnumber] == "") ||
($_POST[message] == "")) {
header ("Location: http://www.mdcomputertraining.co.uk/form.htm");
exit;
}
$msg .= "email sent from www site\n";
$msg .= "senders's name:\t$_POST[name]\n";
$msg .= "senders's email:\t$_POST[email]\n";
$msg .= "senders's tel number:\t$_POST[telnumber]\n";
$msg .= "message:\t$_POST[message]\n";
$to = 'md@mdavies7.plus.com';
$subject = "Web site message";
$mailheaders = "From: My Web site <mdcomputertraining.co.uk>\n";
$mailheaders .= "Reply-To: $_POST[email]\n";
mail ($to, $subject, $msg, $mailheaders);
?>
<html>
<head>
<title>Simple feedback form sent</title>
</head>
<body>
<H1>The following e-mail has been sent</H1>
<p><strong>Name:</strong><br>
<? echo "$_POST[name]"; ?>
<p><strong>Email:</strong><br>
<? echo "$_POST[email]"; ?>
<p><strong>Tel Number:</strong><br>
<? echo "$_POST[telnumber]"; ?>
<p><strong>Message:</strong><br>
<? echo "$_POST[message]"; ?>
</body>
</html>