Jan
If I have a web form script, how would I forward the form info to my e-mail using php? If possible, please cite a source or give a specific example of the code I would need to use. Thank you!
Answer:
ok you can send email with PHP with few easy steps.
this is how it's done.
First of all create your email form with HTML. this is code for it.
and if you want, you can modify it as you want.
Copy this code and paste it into
section of the page.OK now we will see how to create PHP page
create new PHP file and give it's name to "contact.php" and save it to the same folder where you save the HTML file that we created little time before.
and copy this code and paste it in to PHP file.
$to = "TOUR EMAIL ADDRESS HERE";
$Name = trim($_POST['Name']) ? trim($_POST['Name']) : '-';
$Address = trim($_POST['Address']) ? trim($_POST['Address']) : '_';
$Tel = trim($_POST['Tel']) ? trim($_POST['Tel']) : '_';
$Email = trim($_POST['Email']) ? trim($_POST['Email']) : '-' ;
$Comments = trim($_POST['Comments']) ? trim($_POST['Comments']) : '-' ;
$comment = wordwrap($comment, 100, "
\n");
$subject = "Customer Inquiries from web site";
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-Type:text/html; charset=iso-8859-1\n";
$headers .= "From:$email\n";
$headers .= "Return-Path:$email\n";
$message = "
‘>http://www.w3.org/TR/html4/loose.dtd'>
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
a:link {
text-decoration: none;
color: #42557B;
}
a:visited {
text-decoration: none;
color: #42557B;
}
a:hover {
text-decoration: none;
color: #999BBB;
}
a:active {
text-decoration: none;
}
.feedback {
font-family: 'Lucida Sans Unicode';
font-size: 10px;
color: #666666;
}
.link {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #000000;
}
.button {
font-family: 'Lucida Sans Unicode';
font-size: 10px;
color: #000000;
font-weight: normal;
line-height: normal;
font-style: normal;
background-color: #FFFFFF;
background-position: center center;
letter-spacing: normal;
word-spacing: normal;
text-align: center;
vertical-align: middle;
cursor: hand;
}
.style7Copy {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
color: #FFFFFF;
}
.error {
font-family: 'Courier New', Courier, mono;
font-size: 12px;
color: #7C480E;
line-height: normal;
}
.style12 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #FFCC00; }
.style13 {font-family: Arial, Helvetica, sans-serif; font-size: 10px; color: #CCCCCC; }
.style15 {
font-size: 26px;
color: #FFCC00;
font-family: Arial, Helvetica, sans-serif;
}
–>
|
||||||||||
|
|
||||||||||
|
||||||||||
";
mail($to, $subject, $message, $headers);
//header("Location: http://" . $_SERVER['HTTP_HOST']
// . dirname($_SERVER['PHP_SELF'])
// . "/"
// . "confirm.htm");
exit();
?>
in the top of PHP code you can see "YOUR EMAIL ADDRESS HERE" replace it with your email address.
finished!
save this two file to 1 folder and upload it to PHP enabled server and test it .
If this hard to understand please tell me i'll explain it again if you want!
Good luck!
Book Mark it-> del.icio.us | Reddit | Slashdot | Digg | Facebook | Technorati | Google | StumbleUpon | Window Live | Tailrank | Furl | Netscape | Yahoo | BlinkList