Log in
Register
Menu
Log in
Register
Home
What's new
Latest activity
Authors
Forums
New posts
Search forums
What's new
New posts
Latest activity
Members
Current visitors
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Miscellaneous Sections
Tech Head - The Technology Section
Computer Discussion
Confused by HTML online inquiry form
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="smoggy07" data-source="post: 892992" data-attributes="member: 298987"><p>add this in place of your code above</p><p></p><p>[code]</p><p><form name="contactform" method="post" action="send_form_email.php"></p><p></p><p><table width="450px"></p><p></p><p><tr></p><p></p><p><td valign="top"></p><p></p><p><label for="name">Name*</label></p><p></p><p></td></p><p></p><p><td valign="top"></p><p></p><p><input type="text" name="name" maxlength="50" size="30"></p><p></p><p></td></p><p></p><p></tr></p><p></p><p></p><p><tr></p><p></p><p><td valign="top"></p><p></p><p><label for="email">Email Address *</label></p><p></p><p></td></p><p></p><p><td valign="top"></p><p></p><p><input type="text" name="email" maxlength="80" size="30"></p><p></p><p></td></p><p></p><p></tr></p><p></p><p><tr></p><p></p><p><td valign="top"></p><p></p><p><label for="comments">Comments *</label></p><p></p><p></td></p><p></p><p><td valign="top"></p><p></p><p><textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea></p><p></p><p></td></p><p></p><p></tr></p><p></p><p><tr></p><p></p><p><td colspan="2" style="text-align:center"></p><p></p><p><input type="submit" value="Submit"></p><p></td></p><p></p><p></tr></p><p></p><p></table></p><p></p><p></form></p><p>[/code]</p><p></p><p>then make a new php page, name it "send_form_email.php" and add the following code to it, changing "you @ yourdomain . com" to your email and "Your email subject line" to what ever you want</p><p></p><p>[code]</p><p><?php</p><p></p><p>if(isset($_POST['email'])) {</p><p></p><p></p><p></p><p>// EDIT THE 2 LINES BELOW AS REQUIRED</p><p></p><p>$email_to = "you@yourdomain.com";</p><p></p><p>$email_subject = "Your email subject line";</p><p></p><p></p><p></p><p></p><p></p><p>function died($error) {</p><p></p><p>// your error code can go here</p><p></p><p>echo "We are very sorry, but there were error(s) found with the form you submitted. ";</p><p></p><p>echo "These errors appear below.<br /><br />";</p><p></p><p>echo $error."<br /><br />";</p><p></p><p>echo "Please go back and fix these errors.<br /><br />";</p><p></p><p>die();</p><p></p><p>}</p><p></p><p></p><p></p><p>// validation expected data exists</p><p></p><p>if(!isset($_POST['name']) ||</p><p></p><p>!isset($_POST['email']) ||</p><p></p><p>!isset($_POST['comments'])) {</p><p></p><p>died('We are sorry, but there appears to be a problem with the form you submitted.');</p><p></p><p>}</p><p></p><p></p><p></p><p>$first_name = $_POST['name']; // required</p><p></p><p>$email_from = $_POST['email']; // required</p><p></p><p>$comments = $_POST['comments']; // required</p><p></p><p>$error_message = "";</p><p></p><p>$email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';</p><p></p><p>if(!preg_match($email_exp,$email_from)) {</p><p></p><p>$error_message .= 'The Email Address you entered does not appear to be valid.<br />';</p><p></p><p>}</p><p></p><p>$string_exp = "/^[A-Za-z .'-]+$/";</p><p></p><p>if(!preg_match($string_exp,$name)) {</p><p></p><p>$error_message .= 'The Name you entered does not appear to be valid.<br />';</p><p></p><p>}</p><p></p><p>if(strlen($comments) < 2) {</p><p></p><p>$error_message .= 'The Comments you entered do not appear to be valid.<br />';</p><p></p><p>}</p><p></p><p>if(strlen($error_message) > 0) {</p><p></p><p>died($error_message);</p><p></p><p>}</p><p></p><p>$email_message = "Form details below.\n\n";</p><p></p><p></p><p>function clean_string($string) {</p><p></p><p>$bad = array("content-type","bcc:","to:","cc:","href");</p><p></p><p>return str_replace($bad,"",$string);</p><p></p><p>}</p><p></p><p></p><p>$email_message .= "First Name: ".clean_string($name)."\n";</p><p></p><p>$email_message .= "Email: ".clean_string($email_from)."\n";</p><p></p><p>$email_message .= "Comments: ".clean_string($comments)."\n";</p><p></p><p></p><p></p><p>// create email headers</p><p></p><p>$headers = 'From: '.$email_from."\r\n".</p><p></p><p>'Reply-To: '.$email_from."\r\n" .</p><p></p><p>'X-Mailer: PHP/' . phpversion();</p><p></p><p>@mail($email_to, $email_subject, $email_message, $headers);</p><p></p><p>?></p><p></p><p><!-- include your own success html here --></p><p></p><p></p><p></p><p>Thank you for contacting us. We will be in touch with you very soon.</p><p></p><p></p><p></p><p><?php</p><p></p><p>}</p><p></p><p>?></p><p>[/code]</p><p></p><p>upload the .php file to the same directory as your contact form and you should be good to go</p><p></p><p>The above is a working example but you'll need to add a captcha or something to beat the spammers</p></blockquote><p></p>
[QUOTE="smoggy07, post: 892992, member: 298987"] add this in place of your code above [code] <form name="contactform" method="post" action="send_form_email.php"> <table width="450px"> <tr> <td valign="top"> <label for="name">Name*</label> </td> <td valign="top"> <input type="text" name="name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top"> <label for="email">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="80" size="30"> </td> </tr> <tr> <td valign="top"> <label for="comments">Comments *</label> </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> </td> </tr> </table> </form> [/code] then make a new php page, name it "send_form_email.php" and add the following code to it, changing "you @ yourdomain . com" to your email and "Your email subject line" to what ever you want [code] <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "you@yourdomain.com"; $email_subject = "Your email subject line"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['name']) || !isset($_POST['email']) || !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['name']; // required $email_from = $_POST['email']; // required $comments = $_POST['comments']; // required $error_message = ""; $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/'; if(!preg_match($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "/^[A-Za-z .'-]+$/"; if(!preg_match($string_exp,$name)) { $error_message .= 'The Name you entered does not appear to be valid.<br />'; } if(strlen($comments) < 2) { $error_message .= 'The Comments you entered do not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you very soon. <?php } ?> [/code] upload the .php file to the same directory as your contact form and you should be good to go The above is a working example but you'll need to add a captcha or something to beat the spammers [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Miscellaneous Sections
Tech Head - The Technology Section
Computer Discussion
Confused by HTML online inquiry form
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top