Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 06-18-2009, 12:22 PM PHP Contact Form
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
Hi,

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">&nbsp;&nbsp;<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
__________________
Alex
konetch is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-19-2009, 02:58 AM Re: PHP Contact Form
jason_alan's Avatar
Super Talker

Posts: 100
Name: Jason
Location: Seattle, WA
Trades: 0
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
jason_alan is offline
Reply With Quote
View Public Profile
 
Old 06-19-2009, 09:16 AM Re: PHP Contact Form
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
Yeah, I was working on it some more and found the answer. Thank you though.

Alex
__________________
Alex
konetch is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to PHP Contact Form
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12368 seconds with 12 queries