Badwolf Posted January 20, 2015 Share Posted January 20, 2015 (php is a weakness) Here is the HTML portion for the form: <form action="send_form_email.php" id="contacts-form" method="post"> <fieldset> <div class="grid3 first"> <label>Name:<br /> <input type="text" name="name" value="" id="name" /> </label> <label>E-mail:<br /> <input type="email" value="" name ="email" id="email" /> </label> </div> <div class="grid3">Message:<br /> <textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea> <div class="alignleft"> <a href="#" class="alt" onClick="document.getElementById('contacts-form').reset()">Clear</a> <a href="#" class="alt" onClick="document.getElementById('contacts-form').submit()">Submit</a> </div> </div> </fieldset> </form> Here is the PHP portion <?php $ToEmail = 'abcdefg12345@gmail.com'; $EmailSubject = 'Site contact form'; $mailheader = "From: ".$_POST["email"]."\r\n"; $mailheader .= "Reply-To: ".$_POST["email"]."\r\n"; $mailheader .= "Content-type: text/html; charset=iso-8859-1\r\n"; $MESSAGE_BODY = "Name: ".$_POST["name"].""; $MESSAGE_BODY .= "Email: ".$_POST["email"].""; $MESSAGE_BODY .= "Comment: ".nl2br($_POST["comment"]).""; mail($ToEmail, $EmailSubject, $MESSAGE_BODY, $mailheader) or die ("Failure"); ?> <3 Quote Link to comment https://forums.phpfreaks.com/topic/294094-simple-phphtml-contact-form-giving-me-trouble-any-advice/ Share on other sites More sharing options...
CroNiX Posted January 20, 2015 Share Posted January 20, 2015 So...what trouble is it giving you? What's the problem? Quote Link to comment https://forums.phpfreaks.com/topic/294094-simple-phphtml-contact-form-giving-me-trouble-any-advice/#findComment-1503570 Share on other sites More sharing options...
brotherZ Posted February 12, 2015 Share Posted February 12, 2015 Where is the javascript code that your form invokes? Quote Link to comment https://forums.phpfreaks.com/topic/294094-simple-phphtml-contact-form-giving-me-trouble-any-advice/#findComment-1505554 Share on other sites More sharing options...
NetKongen Posted February 14, 2015 Share Posted February 14, 2015 Are your working localhost? If so, the form will probably not send anything Quote Link to comment https://forums.phpfreaks.com/topic/294094-simple-phphtml-contact-form-giving-me-trouble-any-advice/#findComment-1505690 Share on other sites More sharing options...
jeffreyappel Posted March 8, 2015 Share Posted March 8, 2015 (edited) Here you go: <!DOCTYPE html> <html lang="en"> <head></head> <body> <form action="send_form_email.php" id="contacts-form" method="post"> <fieldset> <div class="grid3 first"> <label>Name:<br/> <input type="text" name="name" value="" id="name" /> </label> <br/><label>E-mail:<br/> <input type="email" value="" name ="email" id="email" /> </label> </div> <div class="grid3">Message:<br/> <textarea name="comment" cols="45" rows="6" id="comment" class="bodytext"></textarea> <div class="alignleft"> <a href="#" class="alt" onClick="document.getElementById('contacts-form').reset()">Clear</a> <a href="#" class="alt" onClick="document.getElementById('contacts-form').submit()">Submit</a> </div> </div> </fieldset> </form> </body> <?php if(isset($_POST['submit'])){ $to = "email@example.com"; // this is your Email address $from = $_POST['email']; // this is the sender's Email address $subject = 'Site contact form'; $message = "Name: ".$_POST["name"]."" . "Email: ".$_POST["email"]."" ."Comment: ".nl2br($_POST["comment"]).""; $message2 = "Here is a copy of your message " . $first_name . "\n\n" . $_POST['message']; $headers = "From:" . $from; $headers2 = "From:" . $to; mail($to,$subject,$message,$headers); echo "Mail Sent. Thank you " . ?> </html> Edited March 8, 2015 by jeffreyappel Quote Link to comment https://forums.phpfreaks.com/topic/294094-simple-phphtml-contact-form-giving-me-trouble-any-advice/#findComment-1507861 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.