Jump to content

PHP Contact Form error


oedwards0088

Recommended Posts

Hi,

I have use the below link to make a contact form;

http://www.websitecodetutorials.com/cod ... dation.php

When I submit the form I get an error '22527'. Cant work out what it is and having searched I can't make sense of other answers mainly because I am only just starting out in PHP.

 

The Form

                <form  method="post" action="bookingform1.php">
                <ul>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="First Name" name="firstname" maxlength="25"></input></li>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Last Name" name="lastname" maxlength="25"></input></li>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Nationality" name="nationality" maxlength="25"></input></li>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Date Of Birth" name="dob" maxlength="25"></input></li>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Gender" name="gender" maxlength="15"></input></li>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Occupation" name="occupation" maxlength="40"></input></li>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Home Address" name="address" maxlength="80"></input></li>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="E-mail Address" name="email" maxlength="80"></input></li>
                <li class='field'><input class="xwide text input" id='iyc-form-width' type="text" placeholder="Telephone Number" name="telephone" maxlength="25"></input></li>
                <p id='iyc-bold'>Your preferred choice of programme date</p>
                   <li class="field" id='text_align_left'>
                     <div class="picker" id='iyc-picker-width'>
                       <select name="first">
                           <option>October 12-19th 2013</option>
                      <option>November 16-23rd 2013</option>
                      <option>January 18-25th 2014</option>
                      <option>February 15-22nd 2014</option>
                      <option>March 15-22nd 2014</option>
                       </select>
                     </div>
                   </li>
                <p id='iyc-bold'>Your second choice, (should your preferred date be unavailable)</p>
                   <li class="field" id='text_align_left'>
                     <div class="picker" id='iyc-picker-width'>
                       <select name="second">
                           <option>October 12-19th 2013</option>
                      <option>November 16-23rd 2013</option>
                      <option>January 18-25th 2014</option>
                      <option>February 15-22nd 2014</option>
                      <option>March 15-22nd 2014</option>
                       </select>
                     </div>
                   </li>
                <p id='iyc-bold'>What experience do you have of the english language (self-taught/lessons/on-line programmes/immersion programmes)</p>
                <li class='field'><textarea class="input textarea" rows="6" placeholder="Background & experience" name="experience" maxlength="600"></textarea></li>
                <p id='iyc-bold'>Why do you want to attend the programme? (practice the language/to get a job/promotion/expand career opportunities/social)</p>
                <li class='field'><textarea class="input textarea" rows="6" placeholder="What do you want to get out?" name="why" maxlength="600"></textarea></li>
                <p id='iyc-bold'>How did you hear about the A.B.C. Experience Programme?</p>
                <li class='field'><textarea class="input textarea" rows="6" placeholder="How did you find us?" name="how" maxlength="600"></textarea></li>   
                <p id='iyc-bold'>Additional information (include any dietary or other special needs you may require.)</p>
                <li class='field'><textarea class="input textarea" rows="6" placeholder="Additional information" name="info" maxlength="600"></textarea></li>
                <li class="field"><label class="checkbox" for="checkbox1" id='text_align_left'><input name="checkbox1" type="checkbox" id="checkbox1" name="terms" value="0"><span></span> *By ticking this box you accept our terms and conditions as per the below</label></li>
                <div class="pretty warning danger btn icon-left info-circled" id='iyc-btn'><a href="termsandconditions.pdf" target="_blank">Terms & Conditions</a></div>         
                </ul>
                <div align="center">

                   <!-- <h4>For e-mail security purposes please enter in the words above and then click submit below.</h4> -->
                </div>
                <div class="pretty medium default btn" style='margin-top:20px;'><input type="submit" value="Submit"></input></div>
             </form>
    <?php
    // Input Your Personal Information Here
    $mailto = 'oliver@edwardsltd.co.uk' ;
    $from = "ABC Experience England Website - Participants" ;
    $formurl = "http://www.dev.abcexperienceengland.co.uk/bookingform1.php" ;
    $errorurl = "http://www.dev.abcexperienceengland.co.uk/formmailerror.php" ;
    $thankyouurl = "http://www.dev.abcexperienceengland.co.uk/thankyou.php" ;
    // End Edit

    // prevent browser cache
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
    header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
    header("Cache-Control: no-store, no-cache, must-revalidate");
    header("Cache-Control: post-check=0, pre-check=0", false);
    header("Pragma: no-cache");

    function remove_headers($string) {
      $headers = array(
        "/to\:/i",
        "/from\:/i",
        "/bcc\:/i",
        "/cc\:/i",
        "/Content\-Transfer\-Encoding\:/i",
        "/Content\-Type\:/i",
        "/Mime\-Version\:/i"
      );
      if (preg_replace($headers, '', $string) == $string) {
        return $string;
      } else {
        die('You think Im spammy? Spammy how? Spammy like a clown, spammy?');
      }
    }

    $uself = 0;
    $headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;

    if (!isset($_POST['email'])) {
       header( "Location: $errorurl" );
       exit ;
    }

    // Input Your Personal Information Here
    $firstname = remove_headers($_POST['firstname']);
    $lastname = remove_headers($_POST['lastname']);
    $nationality = remove_headers($_POST['nationality']);
    $dob = remove_headers($_POST['dob']);
    $gender = remove_headers($_POST['gender']);
    $occupation = remove_headers($_POST['occupation']);
    $homeaddress = remove_headers($_POST['homeaddress']);
    $email = remove_headers($_POST['email']);
    $telephone = remove_headers($_POST['telephone']);
    $first = remove_headers($_POST['first']);
    $second = remove_headers($_POST['second']);
    $experience = remove_headers($_POST['experience']);
    $why = remove_headers($_POST['why']);
    $how = remove_headers($_POST['how']);
    $info = remove_headers($_POST['info']);
    $terms = remove_headers($_POST['terms']);
    $http_referrer = getenv( "HTTP_REFERER" );
    // End Edit

    if (!preg_match("/^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i",$email)) {
    header( "Location: $errorurl" );
        exit ;
    }

    // Input Your Personal Information Here
    if (empty($firstname) || empty($lastname) || empty($nationality) || empty($dob) || empty($gender) || empty($occupation) || empty($homeaddress) ||
       empty($email) || empty($telephone) || empty($first) || empty($second) || empty($experience) || empty($why) || empty($how) || empty($info) ||
       empty($terms)) {
       header( "Location: $errorurl" );
       exit ;
    }
    // End Edit

    if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
       header( "Location: $errorurl" );
       exit ;
    }
    if (get_magic_quotes_gpc()) {
       $comments = stripslashes( $comments );
    }

    // sets max amount of characters in comments area (edit as nesesary)
    if (strlen($comments) > 1250) {
    $comments=substr($comments, 0, 1250).'...';
    }
    // End Edit

    $message =
       "This message was sent from:\n" .
       "$http_referrer\n\n" .
       
       // Input Your Personal Information Here
       "First Name: $firstname\n\n" .
       "Last Name: $lastname\n\n" .
       "Nationality: $nationality\n\n" .
       "DOB: $dob\n\n" .
       "Gender: $gender\n\n" .
       "occupation: $occupation\n\n" .
       "homeaddress: $homeaddress\n\n" .
       "E-mail: $email\n\n" .
       "Telephone: $telephone\n\n" .
       "first: $first\n\n" .
       "second: $second\n\n" .
       "What experience do you have: $experience\n\n" .
       "Why do you want: $why\n\n" .
       "How did you hear about us: $how\n\n" .
       "Other Information: $info\n\n" .
       "Agree to the terms: $terms\n\n" .
       "\n\n------------------------------------------------------------\n" ;
       // End Edit

    mail($mailto, $from, $message,
       "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep );
    header( "Location: $thankyouurl" );
    exit ;

    ?>

http://www.dev.abcexperienceengland.co.uk/

 

I am using GUMBY as the CSS framework.

As mentioned I am a newbie to PHP so apologise in advance for any stupid mistakes. Any help to get this working would be much appreciated.

Thanks in advance

Olly Edwards

Edited by oedwards0088
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.