...

View Full Version : Contact Form Has Contractions Error



Krayfish
11-20-2012, 09:12 PM
I'm using a pre-built contact form. If you enter "can't" instead of "cant" in the message field & hit send, it generates the following error:

"Invalid characters ( # @ ^ ' " \ * = ; % < > ` ~ + ) entered in text area (for example if you wrote the word that's take out the '). Please go back and fix, Then click send!".

My knowledge of PHP is limited. Can you help me fix this? :confused:

...Thanks





<?php
#This line must remain here. Thankyou. 'Hacker Fighter' PHP contact form V 1.1. Copyright 2011 Joshua Luther Hunt-Smith, all rights reserved. Project page URL: servertosite.com/php-contact-forms-open-source/hacker-fighter.html This project is released under the BSD license: creativecommons.org/licenses/BSD/

function mailio($chk){
if(preg_match('/^[\w.-]+@[\w.-]+\.([\w.]{2,10})\z/',$chk) && strlen($chk) < 70)
{;}else if($chk===''){die('<h1>Email address input left empty. Please go back and put in your email address <span>(!)</span></h1>');}else{die('<h1>Invalid email address entered. Please go back and fix it before sending <span>(!)</span></h1>');}}
function texti($zn){
if(!preg_match('/^([\w-\s]+)\z/',$zn) && strlen($chk) < 70){die('<h1>Invalid characters entered in a text/number field or else text exceeds 70 character limit (Note: The main message text area has a much larger 20000 character limit). Please go back and fix before sending <span>(!)</span></h1>');}}
function txar($xa){
if(!preg_match('/^([\w$&!?.,-\s\:\/]+)\z/',$xa)){die('<h1>Invalid characters ( # @ ^ ' &quot; \ * = ; % &lt; &gt; ` ~ + ) entered in text area (for example if you wrote the word that's take out the '). Please go back and fix, Then click send <span>(!)</span></h1>');}}

$subject= $_SERVER['HTTP_HOST'];
$sbot= $_POST['text'];
$name= $_POST['name'];
$email= $_POST['email'];
$deps= $_POST['whd'];
$msg= $_POST['message'];

//The list of email addresses shown below need to be changed to your receiving email addresses, please only change between the two ' ' in each instance. if you want more or less email addresses, copy or remove the whole line that says case 3 and either paste it below case 3, but rename it as case 4, you can repeat this for as many as you want, or to remove just leave it out the line you removed. Just remember that your corrsponding inputs in the contact interface will need to match and have more options and numerically numbered values added or deleted.
switch($deps){
case 1:$you='reception@receivingdomainhere.com';break;
case 2:$you='dispatch@receivingdomainhere.com';break;
case 3:$you='warranties@receivingdomainhere.com';break;

default:die('<h1>Hacking Attempted or a Processing Error Occured</h1>');}

if($sbot===''){$sbot;}else{die('<h1>You filled in an input, that was supposed to remain blank as an anti spam measure. Go back and fill in only labeled inputs <span>(!)</span></h1>');}
if(strlen($msg) > 20000){die('<h1>20000 character text limit exceeded in message field, please go back and shorten message <span>(!)</span></h1>');}
mailio($email);
if($name===''){die('<h1>You left the name field empty. Please go back and check that all fields are filled out, then send <span>(!)</span></h1>');}else{texti($name);}
if($msg===''){die('<h1>You didn\'t fill in a message. Please go back and check that all fields are filled out, then send <span>(!)</span></h1>');}else{txar($msg);}
$br= nl2br($msg);
$mx=<<<cb
<h4>Name:</h4> $name
<br />
<h4>Email:</h4> $email
<br />
<h4>Message:</h4>
$br
cb;

$hdrs = "From:$email\r\n";
$hdrs .= 'Content-type: text/html; charset=utf-8' . "\r\n";
mail($you,$subject,$mx,$hdrs);
echo '<h1>Thankyou. Your message has been sent</h1>';
?>

tangoforce
11-20-2012, 10:12 PM
It's supposedly for stopping spammers abusing your form and CC'ing email all over the place. Having said that, there are far better ways than this script - it's not the best I've seen.

If I were you, I'd find another script.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum