Monday, May 24, 2010

I need a really simple php/or perl email form for my site?

Can anyone suggest a really simple form for my yahoo hosted website that allows people to send email from my website to my email account?





I googled for some but a lot have lots of code or want me to pay, I just need three basic boxes.





Name:


Subject:


Comment:








thanks

I need a really simple php/or perl email form for my site?
See the programs in the NMS archive (linked below).
Reply:I'm assuming Yahoo! allows you to use PHP's mail() function, since you mentioned PHP specifically.





===============================


Code begins below


===============================


%26lt;html%26gt;


%26lt;head%26gt;%26lt;/head%26gt;


%26lt;body%26gt;


%26lt;h2%26gt;Simple Mail Form%26lt;/h2%26gt;


%26lt;?


if(isset($submit)) {


//check for email injection attack; refuse if injection


$attack = false;


foreach($_POST as $field =%26gt; $input) {


$input = stripslashes($input);


if(preg_match('/Content-Type: multipart\/mixed/i', $input)) $attack = true;


if($field != 'comment') {


if(preg_match('/\n/', $input)) $attack = true;


if(preg_match('/\r/', $input)) $attack = true;


}


}


if(!$attack) {


// enter the email addy you want the message sent to:


$to = "you@someserver.com";





mail($to, $subject, $comment);


echo "%26lt;p%26gt;Thank you for your comment! We will respond shortly.%26lt;/p%26gt;";


}


}


else {


?%26gt;


%26lt;form id="email" method="post"%26gt;


%26lt;p%26gt;Name: %26lt;input type="text" id="name" name="name" size="30" maxlength="100" /%26gt;%26lt;/p%26gt;


%26lt;p%26gt;Subject: %26lt;input type="text" id="subject" name="subject" size="30" maxlength="100" /%26gt;%26lt;/p%26gt;


%26lt;p%26gt;Comment: %26lt;input type="textarea" id="comment" name="comment" cols="30" rows="10"%26gt;%26lt;/textarea%26gt;%26lt;/p%26gt;


%26lt;p%26gt;%26lt;input type="submit" name="submit" id="submit" value="Submit" /%26gt;%26lt;/p%26gt;


%26lt;/form%26gt;


%26lt;?


}


?%26gt;


No comments:

Post a Comment