Hey there
I wrote php codes for processing to send email but I feel bit hopeless because when you click on send button after filling a form, you got message like "thank you for contacting us". It is working but I still dont receive this email. I have tested it and send to my email when clicked send button but email didnt come through.
I wonder what is wrong?
Maybe you can check out my codes and tell me where is error? I would appreciate your help.
HTML MARKUP (contactformpage.html)
<form name="form1" method="post" action="contactformprocess.php">
<table width="100%" border="0" cellspacing="0" cellpadding="6">
<tr>
<td><label for="email">
<div align="right">Email Address:</div>
</label>
</td>
<td><div align="left">
<input name="email" type="text" id="email" size="35" maxlength="100">
</div></td>
</tr>
<tr>
<td><label for="name">
<div align="right">Name:</div>
</label>
</td>
<td><div align="left">
<input name="name" type="text" id="name" size="35" maxlength="80">
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="comments">Comments:</label>
</div></td>
<td><div align="left">
<textarea name="comments" id="comments" cols="26" rows="5"></textarea>
</div></td>
</tr>
<tr>
<td><div align="right">
<label for="clear"></label>
<input type="reset" name="clear" id="clear" value="Reset Form">
</div></td>
<td><div align="right">
<label for="submit"></label>
<div align="left">
<input type="submit" name="submit" id="submit" value="Send Email!">
</div>
</div></td>
</tr>
</table>
</form>
PHP codes (contactformprocess.php)
<?php
$emailSubject = 'You got message from your website';
$webMaster = 'myname@lantic.net';
$email = $_POST['email'];
$name = $_POST['name'];
$comments = $_POST['comments'];
$body = <<<EOD
<br><hr><br>
Email: $email <br>
Name: $name <br>
Comments: $comments
EOD;
$headers = "Form:$email\r\n";
$headers .= "Content-type: text/html\r\n";
$success = mail($webMaster, $emailSubject, $body, $headers);
$theResults = <<<EOD
<html>
<head>
<title>Process</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body {
background-color: #f1f1f1;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: 12px;
font-style: normal;
line-height: normal;
font-weight: normal;
color: #666666;
text-decoration: none;
}
-->
</style>
</head>
<div>
<div align="left">Thank you for your interest! Your email will be answered very soon!</div>
</div>
</body>
</html>
EOD;
echo "$theResults";
?>
problem with email form in html using php
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: problem with email form in html using php
Try placing the From header after the content type header.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: problem with email form in html using php
Dear me... lol its been a long time since I seen Heredoc being used. lol
Is that thing still being supported? lol
Best wishes
Is that thing still being supported? lol
Best wishes
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: problem with email form in html using php
Is that the <<<EOD code?phphelpme wrote:Heredoc
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: problem with email form in html using php
Yeah social, has been getting changed over the last couple of years and certain things are not allowed any more within the <<< ;
Check it out here:
http://www.php.net/manual/en/language.t ... ax.heredoc
Best wishes
Check it out here:
http://www.php.net/manual/en/language.t ... ax.heredoc
Best wishes
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: problem with email form in html using php
The first time i saw those was when i started learning about sending mail, never could get the script in the book to work until i veered away from heredoc. Thanks for the url 
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Re: problem with email form in html using php
I hate the thing anyway, cant believe it still gets used to be honest. lol
Its a little silly really because you have set stnadards of coding then heredoc goes against all that... lol
No worries about the link Social.
Best wishes
Its a little silly really because you have set stnadards of coding then heredoc goes against all that... lol
No worries about the link Social.
Best wishes