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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Contact Form, Please Wait Message Question

    Hi I am a litle new to PHP and I was wondering if someone could help me out with adding a "please wait.." message/page to this script.

    Thanks so much!

    Code:
    <form name="email" method="POST" action="contact.php" />
    
    <input type="text" name="name" /><br />
    <input type="text" name="email" /><br />
    <input type="text" name="phone" /><br /><br />
    <textarea rows="3" name="message" /></textarea>
    <br /><br />
    <input type="submit" value="Send" name="submit">
    
    </form>
    
    
    
    contact.php
    
    <?php
    
    
    // get posted data into local variables
    $EmailFrom = "webmaster@domain.com";
    $EmailTo = "email@domain.com, email2@domain.com";
    $Subject = "Inquiry from Website.com";
    $name = Trim(stripslashes($_POST['name'])); 
    $email = Trim(stripslashes($_POST['email'])); 
    $phone = Trim(stripslashes($_POST['phone'])); 
    $message = Trim(stripslashes($_POST['message'])); 
    
    
    // Select if you want to check form for standard spam text
      $SpamCheck = "Y"; // Y or N
      $SpamReplaceText = "*content removed*";
    // Error message prited if spam form attack found
    $SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Malicious code content detected.
    </font><br><b>Your IP Number of <b>".getenv("REMOTE_ADDR")."</b> has been logged.</b></p>";
    
    // validation
    $validationOK=true;
    if (!$validationOK) {
      print "<meta http-equiv=\"refresh\" content=\"0;URL=error.htm\">";
      exit;
    }
    
    
    if ($SpamCheck == "Y") {		   
    // Check for Website URL's in the form input boxes as if we block website URLs from the form,
    // then this will stop the spammers wastignt ime sending emails
    if (preg_match("/http/i", "$name")) {echo "$SpamErrorMessage"; exit();} 
    if (preg_match("/http/i", "$email")) {echo "$SpamErrorMessage"; exit();} 
    if (preg_match("/http/i", "$message")) {echo "$SpamErrorMessage"; exit();} 
    
    // Patterm match search to strip out the invalid charcaters, this prevents the mail injection spammer 
      $pattern = '/(;|\||`|>|<|&|^|"|'."\n|\r|'".'|{|}|[|]|\)|\()/i'; // build the pattern match string 
                                
      $name = preg_replace($pattern, "", $name); 
      $email = preg_replace($pattern, "", $email); 
      $message = preg_replace($pattern, "", $message); 
    
    // Check for the injected headers from the spammer attempt 
    // This will replace the injection attempt text with the string you have set in the above config section
      $find = array("/bcc\:/i","/Content\-Type\:/i","/cc\:/i","/to\:/i"); 
      $email = preg_replace($find, "$SpamReplaceText", $email); 
      $name = preg_replace($find, "$SpamReplaceText", $name); 
      $message = preg_replace($find, "$SpamReplaceText", $message); 
      
    // Check to see if the fields contain any content we want to ban
     if(stristr($name, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
     if(stristr($message, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
     
     // Do a check on the send email and subject text
     if(stristr($sendto, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
     if(stristr($subject, $SpamReplaceText) !== FALSE) {echo "$SpamErrorMessage"; exit();} 
    }
    
    $headers  = "From: Website.com <email@domain.com>\r\n";
    $headers .= "Reply-To: ".$name." <".$email.">\r\n";
    $headers .= "Return-Path: ".$name." <".$email.">\r\n";
    
    // prepare email body text
    $Body = "";
    $Body .= "Name: ";
    $Body .= $name;
    $Body .= "\n";
    $Body .= "Email: ";
    $Body .= $email;
    $Body .= "\n";
    $Body .= "Phone: ";
    $Body .= $phone;
    $Body .= "\n";
    $Body .= "Inquiry: ";
    $Body .= $message;
    $Body .= "\n";
    
    // send email 
    $success = mail($EmailTo, $Subject, $Body, $headers); 
    
    // redirect to success page 
    if ($success){
      print "<meta http-equiv=\"refresh\" content=\"0;URL=post-contact.htm\">";
    }
    else{
      print "<meta http-equiv=\"refresh\" content=\"0;URL=post-contact-not-sent.htm\">";
    }
    ?>

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    At what point in your webpage process do you want "please wait" to display and what would we be waiting for?

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm thinking right when they click submit? The actual form I'm using has quadruple the amount of inputs than this example that's why I want a please wait message.

    Thank you

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You can use Javascript for that... no need to bother PHP with it. Look into the onsubmit() event:

    http://www.w3schools.com/js/js_events.asp

    You then set up an invisible DIV with the please wait message in it, and use document.getElementById("msgdiv").style.visibility="visible"; in your Javascript function to make it visible.

    http://www.w3schools.com/htmldom/pro...visibility.asp

  • #5
    Regular Coder
    Join Date
    Jul 2007
    Posts
    191
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Awesome, thanks so much!


  •  

    Posting Permissions

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