Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Oct 2005
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Contact Form Has Contractions Error

    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?

    ...Thanks


    PHP Code:

    <?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>';
    ?>
    Last edited by Krayfish; 11-20-2012 at 08:21 PM.

  • #2
    Senior Coder
    Join Date
    Feb 2011
    Location
    Your Monitor
    Posts
    4,299
    Thanks
    57
    Thanked 525 Times in 512 Posts
    Blog Entries
    5
    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.
    See my new CodingForums Blog: http://www.codingforums.com/blogs/tangoforce/

    Many useful explanations and tips including: Cannot modify headers - already sent, The IE if (isset($_POST['submit'])) bug explained, unexpected T_CONSTANT_ENCAPSED_STRING, debugging tips and much more!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •