Form Redirection

This is a discussion on "Form Redirection" within the PHP Forum section. This forum, and the thread "Form Redirection are both part of the Program Your Website category.



Go Back   Webforumz.com > Main Forums > Program Your Website > PHP Forum

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Jun 3rd, 2007, 12:35
New Member
Join Date: May 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Question Form Redirection

I have a form on my server and it shows a message "Details sent to Webmaster" if form details are properly sent and "Unable to send message...Please Go back and try again" if details are not sent successfully to me. All this works just fine!!!

Now I was just wondering if it is possible to automatically redirect my visitor...To my homepage(if details have been sent) or back to the form page(if details are not sent) Can I do this?? Please help!!

Last edited by madmax; Jun 4th, 2007 at 16:56.
Reply With Quote

  #2 (permalink)  
Old Jun 4th, 2007, 12:10
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Blake121
Re: Form Redirection

Something like this would do....

Code: Select all
if($sent) {
  header('Location: http://yourdomain.com');
} else {
  header('Location: http://yourdomain.com/form.php');
}
Reply With Quote
  #3 (permalink)  
Old Jun 4th, 2007, 12:39
masonbarge's Avatar
Highly Reputable Member
Join Date: Jan 2006
Location: Atlanta GA
Posts: 631
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Redirection

You can do this on one page, although help is limited without seeing your original code. I've put your form in a separate file "form.inc".
PHP: Select all

<?php
if(isset($_POST['submit']))
    if ((isset(
$_POST['email_address'))&&((preg_match . . . . ))) {
        
$email_address=$_POST['email_address';
    } else {
         
$email_address=FALSE;
    } 

   
etc.
   
    if ((isset(
$email_address))&&(isset($id)) . . . . ) {
    (
mail the email - do not send anything to the browserthen:)
    
header("Location:http://www.mysite.com/mypage.php");
    exit();
   
// you can add variables to the redirect, e.g. mypage.php?id=id
  
} else {
       
error message;
       include(
'form.php');
} else {
include(
'form.php')
}
?>
Just a template. You can just send them to a separate error message page and make them backspace, rather than including the form twice.
Reply With Quote
  #4 (permalink)  
Old Jun 4th, 2007, 16:59
New Member
Join Date: May 2007
Location: India
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Re: Form Redirection

Here is my mailer.php.......What do I do??

Code: Select all
<?php
if(isset($_POST['submit'])) {

$to = "navinpai_kma@yahoo.com";
$subject = "Form Tutorial";
$email_field = $_POST['email'];
$message_field = $_POST['message'];

 
$body = "From: $email_field\n Message: $message_field\n ";
 
echo "Details sent to Webmaster!";
mail($to, $subject, $body);

} else {

echo "Unable to send message...Please Go back and try again";

}
?>
Reply With Quote
  #5 (permalink)  
Old Jun 4th, 2007, 17:35
Reputable Member
Join Date: Apr 2007
Location: Scotland
Age: 17
Posts: 233
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Blake121
Re: Form Redirection

If all you want to do is redirect when the e-mail is sent successfully this will work. It will display "Unable to send message..." if the e-mail is not sent.

Code: Select all
<?php
if(array_key_exists(submit, $_POST)) {

$to = "navinpai_kma@yahoo.com";
$subject = "Form Tutorial";
$email_field = $_POST['email'];
$message_field = $_POST['message'];

 
$body = "From: $email_field\n Message: $message_field\n ";
 
echo "Details sent to Webmaster!";
$mail = mail($to, $subject, $body);

  if($mail) {
    header('Location: http://yoursite.com');
  }
  else {
    echo "Unable to send message...Please Go back and try again";
  }

}
?>
Reply With Quote
Reply

Tags
redirection, form

Thread Tools

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Frame redirection with PHP linchpin311 PHP Forum 2 May 17th, 2007 17:35
Upload redirection Ross PHP Forum 8 Feb 28th, 2007 23:32
remove redirection expressweb Implemented Suggestions 6 Jul 21st, 2005 22:24
redirection problem iamzoli PHP Forum 12 Apr 11th, 2004 08:48


All times are GMT. The time now is 11:30.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43