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 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Contact Us form redirect to home page after submit

    I have developed a contact us page and also PHP code that works perfect. Know the only problem is that after submitting the form it shows only "Message sent" on a new page. I want that after submitting the form page will redirect back to home page. It is only one page "Landing Page". Here is the PHP code.
    Code:
    <?php
        
        if(!$_POST) exit;
        
        $email = $_POST['email'];
        
        
        //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
        if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
        	$error.="Invalid email address entered";
        	$errors=1;
        }
        if($errors==1) echo $error;
        else{
        	$values = array ('name','email','message','phone');
        	$required = array('name','email','message','phone');
        	 
        	$your_email = "todd@toddandersonhomes.com";
        	$email_subject = "Free Credit Report: ".$_POST['subject'];
        	$email_content = "Following is the free credit report detail from client:\n";
        	
        	foreach($values as $key => $value){
        	  if(in_array($value,$required)){
        		if ($key != 'subject' && $key != 'company') {
        		  if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
        		}
        		$email_content .= $value.': '.$_POST[$value]."\n";
        	  }
        	}
        	 
        	if(@mail($your_email,$email_subject,$email_content)) {
        		echo 'Message sent!'; 
        	} else {
        		echo 'ERROR!';
        	}
        }
        ?>
    HTML Code:

    Code:
    <form action="contact.php" method="post">
        
                                <div class="formele">
                        <ul>
                            <li>
                            <label>Name:</label>
                            <input type="text" id="name" name="name" class="text2" />
                            </li>
                            <li>
                            <label>Telephone:</label>
                            <input id="name" type="text" name="phone" class="text2" />
                            </li>
                            <li>
                            <label>E-mail:</label>
                            <input id="name" type="text" name="email" class="text2" />                    
                            </li>
                            <li>
                            <label>Address:</label>
                            <input id="name" type="text" name="message" class="text2" />                    
                            </li>
                            
                            <li class="button">
                            <input type="image" type="text" src="images/submit.png" />                  
                            </li>
                        </ul>           
                    </div><!--Contact Form Ends Here -->
                    </form>
    Here is the link of the page: http://www.designsblessing.com/Landingpages/

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    PHP Code:
    if(@mail($your_email,$email_subject,$email_content)) {
                
    //echo 'Message sent!'; 
                  
    header("Location:http://www.designsblessing.com");
                  exit();
            } 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,863
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    PHP Code:
    if(@mail($your_email,$email_subject,$email_content)) {
                
    //echo 'Message sent!'; 
                  
    header("Location:http://www.designsblessing.com");
                  exit();
            } 
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Tags for this Thread

    Posting Permissions

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