Advanced Search

Results 1 to 2 of 2

Thread: Php contactform handler with issues

  1. #1
    Join Date
    May 2013
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Php contactform handler with issues

    I have been looking at several pages of sollutions but I am lost in the woods.

    Obviously i am using a contactform on my website, I have found a working script written by Betty, and I have contacted this person for some support however that was 5 days ago and no answer yet.

    the Html part of the contact form asks for:

    name,
    surname,
    email address,
    message,
    phonenumber,

    If any of these required fields are not or not correctly filled in the PHP script opens up a white pages filled with error messages.
    Than the user has to arrow back to the form page and start from scratch, this is ot only anoying but painfull, if you just typed a message of 1000 words and you typed your phone number wrong you get to do it all again lol

    further more there is no thank you except after submitting where it clears the form reloads the page and in the addressbar it states the name of the page/thankyou

    I have tried to tweak a few things and messed it up badly, i ended up spamming my own e-mail with over 50 test messages I need help!

    Since I can not upload the php script I have copied and past it here,

    What I would like to have:

    error messages in a windows popup without clearing the entire form
    a thank you message in a windows popup and clear the form/reload the page

    ***** original php script ****
    PHP Code:
    <?php 

        
    #**********************************************
        # Contact Formulier vanBetty
        #**********************************************

    if(isset($_POST['email'])) {
        
        
    // Pas deze twee regels aan.
        
    $email_to "seccondbest@aol.com";
        
    $email_subject "Bericht van een bezoeker";
        
        
        function 
    died($error) {
            
    // je foutbericht staat hier
            
    echo "Het spijt ons, vanwege een fout is het formulier niet verzonden. ";
            echo 
    "Deze fout(en) tonen zich hieronder.<br /><br />";
            echo 
    $error."<br /><br />";
            echo 
    "Ga aub terug om de velden correct in te vullen.<br /><br />";
            die();
        }
        
        
    // validation expected data exists
        
    if(!isset($_POST['first_name']) ||
            !isset(
    $_POST['last_name']) ||
            !isset(
    $_POST['email']) ||
            !isset(
    $_POST['telephone']) ||
            !isset(
    $_POST['comments'])) {
            
    died('Het spijt ons, er is een probleem opgetredn bij het verzenden van het formulier.');        
        }
        
        
    $first_name $_POST['first_name']; // verplicht
        
    $last_name $_POST['last_name']; // verplicht
        
    $email_from $_POST['email']; // verplicht
        
    $telephone $_POST['telephone']; // niet verplicht
        
    $comments $_POST['comments']; // verplicht
        
        
    $error_message "";
        
    $email_exp "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$";
      if(!
    eregi($email_exp,$email_from)) {
          
    $error_message .= 'Het emailadres is niet geldig.<br />';
      }
        
    $string_exp "^[a-z .'-]+$";
      if(!
    eregi($string_exp,$first_name)) {
          
    $error_message .= 'De voornaam is niet geldig.<br />';
      }
      if(!
    eregi($string_exp,$last_name)) {
          
    $error_message .= 'De achternaam is niet geldig.<br />';
      }
      if(
    strlen($comments) < 2) {
          
    $error_message .= 'Het bericht is niet geldig.<br />';
      }
      
    $string_exp "^[0-9 .-]+$";
      if(!
    eregi($string_exp,$telephone)) {
          
    $error_message .= 'Het telefoonnummer is niet geldig.<br />';
      }
      if(
    strlen($error_message) > 0) {
          
    died($error_message);
      }
        
    $email_message "Gegevens formulier.\n\n";
        
        function 
    clean_string($string) {
          
    $bad = array("content-type","bcc:","to:","cc:","href");
          return 
    str_replace($bad,"",$string);
        }
        
        
    $email_message .= "Voornaam: ".clean_string($first_name)."\n";
        
    $email_message .= "Achternaam: ".clean_string($last_name)."\n";
        
    $email_message .= "Email: ".clean_string($email_from)."\n";
        
    $email_message .= "Telefoon: ".clean_string($telephone)."\n";
        
    $email_message .= "Bericht: ".clean_string($comments)."\n";
        
        
    // create email headers
    $headers 'From: '.$email_from."\r\n".
    'Reply-To: '.$email_from."\r\n" .
    'X-Mailer: PHP/' phpversion();
    @
    mail($email_to$email_subject$email_message$headers); 
    header("Location:contact.htm?thankyou"); 
    ?>



    <?
    }
    ?>
    <?PHP
    //Then outside the processing script add 
    If (isset($_GET['thankyou'])){
    echo 
    "Thank you for your email!<br/><br/>";
    }
    ?>
    the last part of this script //Then outside the processing script add if (isset bla bla bla), was my latest attempt to get a thankyou page and dindt work either

    I am at a lost here and realy any help is welcom but pease I am a beginner and learn by tweaking and seeing, i tryed reading and that didnt work

    thanks for reading my post
    Last edited by traq; 05-22-2013 at 07:56 PM. Reason: please use the forum's [PHP] tags for php code

  2. #2
    Join Date
    Apr 2008
    Location
    So.Cal
    Posts
    3,165
    Thanks
    62
    Thanked 446 Times in 435 Posts
    Blog Entries
    7

    Default

    I think you've found a lot of the disadvantages of this script on your own. There are other serious disadvantages as well. I would recommend finding a new example to learn from. You might look at this one, which I was helping someone else with a while back.
    Adrian ~ facebook | gist/github

    ['66.215.156.37','208.75.149.97'] // ip,ip array!
    "Take that sticker *off* your hat; you look stupid" --Wil Wheaton

Similar Threads

  1. Contactform with PHP
    By cljb in forum HTML
    Replies: 1
    Last Post: 01-15-2012, 05:06 PM
  2. Resolved onMouseout event handler
    By twQ in forum JavaScript
    Replies: 2
    Last Post: 12-31-2009, 03:51 AM
  3. JavaScript Handler file
    By Rocking in forum The lounge
    Replies: 6
    Last Post: 05-19-2009, 03:29 PM
  4. Upcoming Events Handler
    By PawClaw in forum Looking for such a script or service
    Replies: 6
    Last Post: 04-21-2009, 01:59 PM
  5. Form Handler Problem
    By belms in forum PHP
    Replies: 1
    Last Post: 06-24-2006, 08:20 PM

Bookmarks

Posting Permissions

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