I'm still really new to PHP, but I am trying to build a contact form. So far I have
PHP Code:
<?php $dontsendemail = 0; $possiblespam = FALSE; $strlenmessage = ""; $email = $_REQUEST['email']; $message = $_REQUEST['message']; $subject = "Twitter Backgraphic/Avatar Sale";$emailaddress = "alex-konetchy@hotmail.com"; 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
Code:
<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.
Just a hint: Twitter and name field values will be in the $_POST['name'] variables. Or $_REQUEST['name'] as you're using. You can add those to your message