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 06-26-2011, 08:26 AM   PM User | #1
cybersystem
New to the CF scene

 
Join Date: Jun 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
cybersystem is an unknown quantity at this point
Smile Redirect to new page after form submit in php

Hello Friends..!

Below is the PHP Codding of ( subscribers script ), But i am experiencing one problem with it, i want when visitors entered there Name And Email, and hits Submit, it will redirect to the new page of my website ( www.mywebsite.com/new-page.html )

Currently its only showing the message -Thank you for subscribing with us

So i just want, that after user or visitor will clicked SUBMIT button, its just redirected to new page or another webpage of my site. As you can see in below image.!

http://img42.imageshack.us/img42/403/subcriber.jpg

I ll be very appreciated if you can help me to solved it

===========Here Is Coding============================

PHP Code:
<?php
extract
($HTTP_GET_VARS);
extract($HTTP_POST_VARS);
if(
$action=="subscribe"){
$id=time();
$rand=rand(10000,1000000000);
if(
$group!="" && $name!="" && $email!=""){
$vef=explode("@",$email);
if(
strlen($vef[0])>="2"&&strlen($vef[1])>="2"){
$lday =date("D d");
$lmonth =date("M");
$lyear =date("Y");
$sdate="$lday-$lmonth-$lyear";
$g=fopen("subscribers/$group/$id$rand&~@&.php","w");
fwrite($g,"<?php \n");
fwrite ($g'$content="');
fwrite ($g$name);
fwrite ($g"|Ä0_è|");
fwrite ($g$email);
fwrite ($g"|Ä0_è|");
fwrite ($g$sdate);
fwrite ($g"|Ä0_è|");
fwrite ($g"\"; ?>");
fclose ($g);
echo
"<FONT COLOR=blue face=arial>[COLOR="Red"]Thank you for subscribing with us<[/COLOR]/FONT><BR>";
}
}else{
echo
"<FONT COLOR=red face=arial>Please fill in the form properly.</FONT><BR>";
}
}
echo 
"<form method=post action=?action=subscribe>";
echo 
"<Table width=80%><TR><TD width=15%></TD>
    <TD width=80%>Name
      <input type='text' name='name' title='Enter Your Name' style='font-size:12px'></TD></TR><TR><TD width=15%>&nbsp;</TD><TD width=80%>Email:
        <input type='text' name='email' title='Enter Email Address' style='font-size:12px'></TD></TR><TR><TD width=15%><input type=hidden name=group 

value='$group'><BR><BR></TD><TD width=80%><input type='submit' value='Submit Your Information' style='font-size:18px'></TD></TR></Table>
</form>"
;

?>
==========Codding Ends===============

Last edited by Inigoesdr; 10-28-2011 at 05:35 PM.. Reason: spelling error
cybersystem is offline   Reply With Quote
Old 06-26-2011, 09:42 AM   PM User | #2
TrevorWeaver
New Coder

 
Join Date: Jun 2011
Posts: 29
Thanks: 13
Thanked 3 Times in 3 Posts
TrevorWeaver is an unknown quantity at this point
If I understand you correctly you need to add some redirect code

PHP Code:
    $url 'thepageyouwanttogoto.html';
    echo 
'<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'
Hope this helps !!!

Regards Trevor
TrevorWeaver is offline   Reply With Quote
Users who have thanked TrevorWeaver for this post:
cybersystem (06-26-2011)
Old 06-26-2011, 09:51 AM   PM User | #3
cybersystem
New to the CF scene

 
Join Date: Jun 2011
Posts: 2
Thanks: 1
Thanked 0 Times in 0 Posts
cybersystem is an unknown quantity at this point
Wow...!

i was searching for this from 4 hours, and finally its working as per my needs

My problem is finally FIXED, with your Solution..

Thank you Trevor, highly appreciated for you time and efforts, it wont be easy without your help.!

Last edited by cybersystem; 06-26-2011 at 09:53 AM.. Reason: speeling mistake
cybersystem is offline   Reply With Quote
Old 06-26-2011, 10:12 AM   PM User | #4
TrevorWeaver
New Coder

 
Join Date: Jun 2011
Posts: 29
Thanks: 13
Thanked 3 Times in 3 Posts
TrevorWeaver is an unknown quantity at this point
Just happy you can now move forward !!!!

Regards Trevor
TrevorWeaver is offline   Reply With Quote
Old 10-28-2011, 05:32 PM   PM User | #5
rachab
New to the CF scene

 
Join Date: Oct 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
rachab is an unknown quantity at this point
PHP Contact Form Rediecrt

Quote:
Originally Posted by TrevorWeaver View Post
If I understand you correctly you need to add some redirect code

PHP Code:
    $url 'thepageyouwanttogoto.html';
    echo 
'<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'
Hope this helps !!!

Regards Trevor
Hi there,
I m just wondering if u can help with this matter:
I m using in my website the PhP Redirect code that you posted, it worked perfectly but only in google Chrome, not in firefox or internet explorer.
Here my PHP code, I would be greatful if u can help with that:


PHP 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','subject','message');
    
$required = array('name','email','subject','message');
     
    
$your_email "me@mine.co.uk";
    
$email_subject "Enquiry: ".$_POST['subject'];
    
$email_content "Enquiry message:\n";
    
    foreach(
$values as $key => $value){
      if(
in_array($value,$required)){
        if (
$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)) 
    {   
        
$url 'http://www.mine.co.uk/thankyou.html"';
    echo 
'<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    } else {
        echo 
'ERROR!';
    
    }
}
?>

Last edited by Inigoesdr; 10-28-2011 at 05:36 PM..
rachab is offline   Reply With Quote
Old 10-28-2011, 10:05 PM   PM User | #6
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,234
Thanks: 4
Thanked 81 Times in 80 Posts
Spookster will become famous soon enough
Quote:
Originally Posted by rachab View Post
Hi there,
I m just wondering if u can help with this matter:
I m using in my website the PhP Redirect code that you posted, it worked perfectly but only in google Chrome, not in firefox or internet explorer.
Here my PHP code, I would be greatful if u can help with that:


PHP 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','subject','message');
    
$required = array('name','email','subject','message');
 
    
$your_email "me@mine.co.uk";
    
$email_subject "Enquiry: ".$_POST['subject'];
    
$email_content "Enquiry message:\n";
 
    foreach(
$values as $key => $value){
      if(
in_array($value,$required)){
        if (
$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)) 
    {   
        
$url 'http://www.mine.co.uk/thankyou.html"';
    echo 
'<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
    } else {
        echo 
'ERROR!';
 
    }
}
?>

I would just use:

PHP Code:
header('Location: http://www.mine.co.uk/thankyou.html'); 

http://php.net/manual/en/function.header.php
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 10-28-2011, 11:11 PM   PM User | #7
rachab
New to the CF scene

 
Join Date: Oct 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
rachab is an unknown quantity at this point
Quote:
Originally Posted by Spookster View Post
I would just use:

PHP Code:
header('Location: http://www.mine.co.uk/thankyou.html'); 

http://php.net/manual/en/function.header.php
Thank you very much
It was helpful, but still the same problem with other browsers, work perfectly in google chrome, I can t figure out where is the mistake.
This is how it looks after changing :

<?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','subject','message');
$required = array('name','email','subject','message');

$your_email = "me@mine.co.uk";
$email_subject = "Enquiry: ".$_POST['subject'];
$email_content = "Enquiry message:\n";

foreach($values as $key => $value){
if(in_array($value,$required)){
if ($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))
header('Location: http://www.mine.co.uk/thankyou.html');
}
?>
rachab is offline   Reply With Quote
Old 10-28-2011, 11:30 PM   PM User | #8
Spookster
Supreme Overlord


 
Spookster's Avatar
 
Join Date: May 2002
Location: Marion, IA USA
Posts: 6,234
Thanks: 4
Thanked 81 Times in 80 Posts
Spookster will become famous soon enough
Quote:
Originally Posted by rachab View Post
Thank you very much
It was helpful, but still the same problem with other browsers, work perfectly in google chrome, I can t figure out where is the mistake.
This is how it looks after changing :

<?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','subject','message');
$required = array('name','email','subject','message');

$your_email = "me@mine.co.uk";
$email_subject = "Enquiry: ".$_POST['subject'];
$email_content = "Enquiry message:\n";

foreach($values as $key => $value){
if(in_array($value,$required)){
if ($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))
header('Location: http://www.mine.co.uk/thankyou.html');
}
?>

Well I know for a fact that the header redirect works with all the browsers. Simply put this and only this into a php file and try it with the other browsers. The problem must be something else in your code that is somehow only affecting specific browsers.

PHP Code:
<?php header('Location: http://www.cnn.com'); ?>
__________________
Spookster
CodingForums Supreme Overlord
All Hail Spookster
Who gave you that Ugging infraction? Yeah that's right it was me!
Spookster is offline   Reply With Quote
Old 01-06-2012, 07:38 PM   PM User | #9
robin1989
New to the CF scene

 
Join Date: Jan 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
robin1989 is an unknown quantity at this point
I have the same problem how can I redirect to a page after the query is send, using this code :
Code:
  <?php
			//init variables
			$cf = array();
			$sr = false;
			
			if(isset($_SESSION['cf_returndata'])){
				$cf = $_SESSION['cf_returndata'];
			 	$sr = true;
			}
            ?>
            <ul id="errors" class="<?php echo ($sr && !$cf['form_ok']) ? 'visible' : ''; ?>">
                <li id="info">There were some problems with your form submission:</li>
                
                <?php 
				if(isset($cf['errors']) && count($cf['errors']) > 0) :
					foreach($cf['errors'] as $error) :
				?>
                <li><?php echo $error ?></li>
                <?php
					endforeach;
				endif;
				?>
            </ul>
            <p id="success" class="<?php echo ($sr && $cf['form_ok']) ? 'visible' : ''; ?>">Thanks for your message! We will get back to you ASAP!</p>
            <form method="post" action="process.php">
                <label for="name">Name: <span class="required">*</span></label>
                <input type="text" id="name" name="name" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['name'] : '' ?>" placeholder="Your Name" required autofocus />
                
                <label for="email">Email Address: <span class="required">*</span></label>
                <input type="email" id="email" name="email" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['email'] : '' ?>" placeholder="youremail@example.com" required />
                
                <label for="telephone">Telephone: </label>
                <input type="tel" id="telephone" name="telephone" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['telephone'] : '' ?>" />
                
                <label for="enquiry">Regarding: </label>
                <select id="enquiry" name="enquiry">
                    <option value="General" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'General') ? "selected='selected'" : '' ?>>General</option>
                    <option value="Sales" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Sales') ? "selected='selected'" : '' ?>>Sales</option>
                    <option value="Support" <?php echo ($sr && !$cf['form_ok'] && $cf['posted_form_data']['enquiry'] == 'Support') ? "selected='selected'" : '' ?>>Support</option>
                </select>
                
                <label for="budget">Budget: </label>
                <input type="tel" id="budget" name="budget" value="<?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['budget'] : '' ?>" />
                
                <label for="message">Message: <span class="required">*</span></label>
              <textarea name="message" class="mssg" id="message" placeholder="Your message must be greater than 20 charcters" required data-minlength="20"><?php echo ($sr && !$cf['form_ok']) ? $cf['posted_form_data']['message'] : '' ?></textarea>
                
                <span id="loading"></span>
      <input name="received" type="submit" id="submit-button" value="Holla!" />
                <p id="req-field-desc"><span class="required">*</span> indicates a required field</p>
            </form>
            <?php unset($_SESSION['cf_returndata']); ?>
robin1989 is offline   Reply With Quote
Old 01-06-2012, 09:48 PM   PM User | #10
robin1989
New to the CF scene

 
Join Date: Jan 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
robin1989 is an unknown quantity at this point
does anybody know how to do this ?
robin1989 is offline   Reply With Quote
Old 01-06-2012, 10:26 PM   PM User | #11
melloorr
Regular Coder

 
Join Date: Dec 2011
Location: NW England
Posts: 194
Thanks: 8
Thanked 15 Times in 15 Posts
melloorr is an unknown quantity at this point
as in
Code:
header("Location: index.php");
?
Edit:
I don't get what you mean, when you send your form, they will go to process.php

Last edited by melloorr; 01-06-2012 at 10:33 PM..
melloorr is offline   Reply With Quote
Users who have thanked melloorr for this post:
robin1989 (01-06-2012)
Old 01-06-2012, 11:33 PM   PM User | #12
robin1989
New to the CF scene

 
Join Date: Jan 2012
Posts: 3
Thanks: 1
Thanked 0 Times in 0 Posts
robin1989 is an unknown quantity at this point
oh, sorry my bad.
I found the header location and I edited it.
Thank you so much
robin1989 is offline   Reply With Quote
Old 03-29-2012, 12:24 PM   PM User | #13
nazshak
New to the CF scene

 
Join Date: Jul 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
nazshak is an unknown quantity at this point
Quote:
Originally Posted by TrevorWeaver View Post
If I understand you correctly you need to add some redirect code

PHP Code:
    $url 'thepageyouwanttogoto.html';
    echo 
'<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">'
Hope this helps !!!

Regards Trevor
Thanks Trevor I solved my Problem with your help.How can i Delay some moments before redirect to another page with a Successful message?

Last edited by nazshak; 03-29-2012 at 12:27 PM..
nazshak is offline   Reply With Quote
Old 03-29-2012, 12:56 PM   PM User | #14
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
PHP Code:
<?php
header
("refresh:5;url=http://cnn.com");
echo 
'In 5 seconds you will be transferred to CNN';
?>
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 09-30-2012, 09:37 AM   PM User | #15
yucar23
New to the CF scene

 
Join Date: Sep 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
yucar23 is an unknown quantity at this point
ilimrehberi

www.ilimrehberi.com redireck
yucar23 is offline   Reply With Quote
Reply

Bookmarks

Tags
php, redirect, submit

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 01:13 PM.


Advertisement
Log in to turn off these ads.