konetch Posted June 18, 2009 Share Posted June 18, 2009 Hi, I'm still really new to PHP, but I am trying to build a contact form. So far I have <?php $dontsendemail = 0; $possiblespam = FALSE; $strlenmessage = ""; $email = $_REQUEST['email']; $message = $_REQUEST['message']; $subject = "Twitter Backgraphic/Avatar Sale";$emailaddress = "[email protected]"; function checkcaptcha() { session_start(); if ($_SESSION["pass"] != $_POST["userpass"]) { die("Sorry, you failed the CAPTCHA. Note that the CAPTCHA is case-sensitive. Please hit your browser back button and try again."); return 1; } } function checkemail($field) { // checks proper syntax if( !preg_match( "/^([a-zA-Z0-9])+([a-zA-Z0-9._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9._-]+)+$/", $field)) { die("Improper email address detected. Please hit your browser back button and try again."); return 1; } } function spamcheck($field) { if(eregi("to:",$field) || eregi("cc:",$field) || eregi("\r",$field) || eregi("\n",$field) || eregi("% 0A",$field)){ $possiblespam = TRUE; }else $possiblespam = FALSE; if ($possiblespam) { die("Possible spam attempt detected. If this is not the case, please edit the content of the contact form and try again."); return 1; } } function strlencheck($field,$minlength,$whichfieldresponse) { if (strlen($field) < $minlength){ die($whichfieldresponse); return 1; } } if ($dontsendemail == 0) $dontsendemail = checkcaptcha($email); if ($dontsendemail == 0) $dontsendemail = checkemail($email); if ($dontsendemail == 0) $dontsendemail = spamcheck($email); if ($dontsendemail == 0) $dontsendemail = spamcheck($subject); if ($dontsendemail == 0) $dontsendemail = strlencheck($email,10,"The email address field is too short. Please hit your browser back button and check your entry.<br>"); if ($dontsendemail == 0) $dontsendemail = strlencheck($message,10,"The message field is too short. Please hit your browser back button and check your entry.<br>"); if ($dontsendemail == 0) $dontsendemail = strlencheck($emailaddress,8,"You have not selected a recipient of your message. Please hit your browser back button and check your entry.<br>"); if ($dontsendemail == 0) {mail($emailaddress,"Subject: $subject",$message,"From: $email" ); echo "Thank you for requesting a TwitBackGraphic. We'll look at your message, and start designing your background.<br><br>Good Luck!<br>";} ?> My HTML is <form method="post" id="captcha_form" name="captcha_form" action="mailform.php"> <div class="over">Name: <br><input type="text" size="30" name="name id="name" value=""> </div> <div class="over">Twitter name @twitter.com(username) <br><input type="text" size="30" name="twitter" id="twitter" value=""> </div> <div class="over">Email address: <br><input type="text" size="30" name="email" id="email" value=""> </div> <?php $subject = "Twitter Backgraphic/Avatar Sale"; ?> <div class="over">How would you like your design? Submit all information you want included in your twitbackgraphic<br><span style="font-size:10px;">(Colors, style, twitter name, and other information you want in your design)</span> <br><textarea name="message" id="message" rows="10" cols="60"><?php echo "</tex" . "tarea>"; ?> <br> </div> <div class="over"> <img src="captcha.php" alt="Captcha"> <span style="font- size:10px;">Note: CaSE sEnsITivE</span> <br><input type="text" name="userpass" value=""> </div> <div style="padding-bottom: 1em;"><input name="submit" type="submit" value="Submit"> </div> </form> Could you show me how to make the name and twitter fields show up in the email message. Thanks for the help Alex Link to comment https://forums.phpfreaks.com/topic/162782-php-contact-form/ Share on other sites More sharing options...
iconicCreator Posted June 18, 2009 Share Posted June 18, 2009 Long story short, Send me a PM and I could build this for you. IC Link to comment https://forums.phpfreaks.com/topic/162782-php-contact-form/#findComment-859235 Share on other sites More sharing options...
rguy84 Posted June 18, 2009 Share Posted June 18, 2009 You need to give all fields a name <input name='twitterID' /> Since you're doing it as a post method you can then do: $twitID = $_POST['twitterID']; Then in your mail script you can do: Twitter Name: $TwitID Link to comment https://forums.phpfreaks.com/topic/162782-php-contact-form/#findComment-859243 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.