Hello, I'm trying to figurate how can I solve this problem with my contact form, whenever I click submit button on my form contact, in my mail I receiving only three correct fields, rest of them (such as message, and 2 other input box - are blank). My code: <form class="form" action=process.php method=POST> <p class="name"> <input type="text" name="name" id="name" placeholder="Your Name" /> <label for="name"></label></p> <p class="name"> <input name="phone" id="phone" placeholder="Phone Number" /> <label for="name"></label></p> <p class="email"> <input type="text" name="email" id="email" placeholder="Your Email" /> <label for="email"></label></p> <p class="web"> <input type="text" name="web" id="web" placeholder="Your Website" /> <label for="web"></label></p> <p class="text"> <textarea class="text2" name="wya" id="infos" placeholder="Who You Are?"></textarea></p> <p class="text"> <textarea class="text3" name="colours" id="colours" placeholder="Your 3 favourite colours"></textarea></p> <p class="text"><textarea name="text" name="message" placeholder="Message"></textarea></p> <div class=g-recaptcha data-sitekey=6LdTGAUTAAAAAF6Z_7sqbHSzGdbNDv1hFHZIdbKp></div> <p class="submit"> <input type="submit" value="Send" /> </p> </form> HTML: <?php $captcha; if(isset($_POST['g-recaptcha-response'])){ $captcha=$_POST['g-recaptcha-response']; } if(!$captcha){ echo '<h2>Please check the the captcha form.</h2>'; exit; } $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=CODE CAPTCHA =".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']); if($response.success==false){ header("Location: http://www.lionet.ie/antispam.html"); } else{ $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $web = $_POST['web']; $infos = $_POST['infos']; $colours = $_POST['colours']; $message = $_POST['message']; $formcontent="Client Name:$name\n Contact Number:$phone \n E-Mail:$email \n Website:$message"; $recipient = "mymail"; $subject = "New Clients question"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); header("Location: http://www.lionet.ie/thanks.html"); } ?> PHP: Please help.
You have two "name" properties in your message textarea: <textarea name="text" name="message" Code (markup): & these $web = $_POST['web']; $infos = $_POST['infos']; $colours = $_POST['colours']; Code (markup): aren't included anywhere in your code to be sent in the email.
Thanks for reply. however still don't get it, does name and id property must be the same in POST and php code? for example "<input type="text" name="web" id="web" placeholder="Your Website" />" "$web = $_POST['web'];"
Change your HTML to <form class="form" action=process.php method=POST> <p class="name"> <input type="text" name="name" id="name" placeholder="Your Name" /> <label for="name"></label></p> <p class="name"> <input name="phone" id="phone" placeholder="Phone Number" /> <label for="name"></label></p> <p class="email"> <input type="text" name="email" id="email" placeholder="Your Email" /> <label for="email"></label></p> <p class="web"> <input type="text" name="web" id="web" placeholder="Your Website" /> <label for="web"></label></p> <p class="text"> <textarea class="text2" name="wya" id="infos" placeholder="Who You Are?"></textarea></p> <p class="text"> <textarea class="text3" name="colours" id="colours" placeholder="Your 3 favourite colours"></textarea></p> <p class="text"><textarea name="message" placeholder="Message"></textarea></p> <div class=g-recaptcha data-sitekey=6LdTGAUTAAAAAF6Z_7sqbHSzGdbNDv1hFHZIdbKp></div> <p class="submit"> <input type="submit" value="Send" /> </p> </form> Code (markup): and your PHP code to: <?php $captcha; if(isset($_POST['g-recaptcha-response'])){ $captcha=$_POST['g-recaptcha-response']; } if(!$captcha){ echo '<h2>Please check the the captcha form.</h2>'; exit; } $response=file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret=CODE CAPTCHA =".$captcha."&remoteip=".$_SERVER['REMOTE_ADDR']); if($response.success==false){ header("Location: http://www.lionet.ie/antispam.html"); } else{ $name = $_POST['name']; $phone = $_POST['phone']; $email = $_POST['email']; $web = $_POST['web']; $infos = $_POST['infos']; $colours = $_POST['colours']; $message = $_POST['message']; $formcontent="Client Name:$name\n Contact Number:$phone \n E-Mail:$email \n Colours:$colours \n Infos:$infos \n Web:$web \n Website:$message"; $recipient = "mymail"; $subject = "New Clients question"; $mailheader = "From: $email \r\n"; mail($recipient, $subject, $formcontent, $mailheader) or die("Error!"); header("Location: http://www.lionet.ie/thanks.html"); } ?> Code (markup):
Everything works great, I got it, the name and id has to be the same like in php, thank you so much papa! Also, on my mail I'm getting as new email "." symbol only (in thread area) how can I solve this?
When I'm opening my email, after submitted message, I'm getting only "." in thread (however everything works correct)
Try changing $mailheader = "From: $email \r\n"; Code (markup): to $mailheader = "From: $email <$email>"; Code (markup): Not sure if that'll work.
Btw - ID and name does NOT have to be the same - but $_POST only cares about the name-attribute. The ID can be whatever you want it to be. (Although it's often easier to just use the same ID and name)
Just a side note, might help cut down on the code bloat and punch up your semantics. First stop calling labels and their inputs "paragraphs" -- they aren't. Would also be nice if your labels ACTUALLY had content and you weren't misusing and outright abusing PLACEHOLDER. http://www.pardot.com/faqs/forms/placeholders-and-labels/ http://www.webaxe.org/placeholder-attribute-is-not-a-label/ http://baymard.com/blog/false-simplicity Even the HTML 5 specification says it.... and I quote: "The placeholder attribute should not be used as a replacement for a label." http://www.w3.org/TR/html5/forms.html#the-placeholder-attribute I'm increasingly shocked that people can get this far into building a page in terms of HTML and back-side code like PHP, but still not manage to have learned how to use HTML properly. NOT really related to your problem (of not using 'names' set the markup while using 'names' that arent), but that form is such a poorly written inaccessible mess I thought it should at least be mentioned.