Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 04-24-2012, 08:12 AM   PM User | #1
freelancekaleem
New to the CF scene

 
Join Date: Apr 2011
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
freelancekaleem is an unknown quantity at this point
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/
freelancekaleem is offline   Reply With Quote
Old 04-24-2012, 08:38 AM   PM User | #2
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
PHP Code:
if(@mail($your_email,$email_subject,$email_content)) {
            
//echo 'Message sent!'; 
              
header("Location:http://www.designsblessing.com");
              exit();
        } 
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Old 04-24-2012, 08:38 AM   PM User | #3
abduraooft
Supreme Master coder!

 
abduraooft's Avatar
 
Join Date: Mar 2007
Location: N/A
Posts: 14,678
Thanks: 158
Thanked 2,182 Times in 2,169 Posts
abduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really niceabduraooft is just really nice
PHP Code:
if(@mail($your_email,$email_subject,$email_content)) {
            
//echo 'Message sent!'; 
              
header("Location:http://www.designsblessing.com");
              exit();
        } 
__________________
Quote:
The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)
abduraooft is offline   Reply With Quote
Reply

Bookmarks

Tags
php

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:55 PM.


Advertisement
Log in to turn off these ads.