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

    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

  • #2
    New Coder
    Join Date
    Jun 2011
    Posts
    29
    Thanks
    13
    Thanked 3 Times in 3 Posts
    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

  • Users who have thanked TrevorWeaver for this post:

    cybersystem (06-26-2011)

  • #3
    New to the CF scene
    Join Date
    Jun 2011
    Posts
    2
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #4
    New Coder
    Join Date
    Jun 2011
    Posts
    29
    Thanks
    13
    Thanked 3 Times in 3 Posts
    Just happy you can now move forward !!!!

    Regards Trevor

  • #5
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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.

  • #6
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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

  • #7
    New to the CF scene
    Join Date
    Oct 2011
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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');
    }
    ?>

  • #8
    Supreme Overlord Spookster's Avatar
    Join Date
    May 2002
    Location
    Marion, IA USA
    Posts
    6,273
    Thanks
    4
    Thanked 83 Times in 82 Posts
    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

  • #9
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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']); ?>

  • #10
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    does anybody know how to do this ?

  • #11
    Regular Coder
    Join Date
    Dec 2011
    Location
    NW England
    Posts
    194
    Thanks
    8
    Thanked 15 Times in 15 Posts
    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.

  • Users who have thanked melloorr for this post:

    robin1989 (01-06-2012)

  • #12
    New to the CF scene
    Join Date
    Jan 2012
    Posts
    3
    Thanks
    1
    Thanked 0 Times in 0 Posts
    oh, sorry my bad.
    I found the header location and I edited it.
    Thank you so much

  • #13
    New to the CF scene
    Join Date
    Jul 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #14
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    PHP Code:
    <?php
    header
    ("refresh:5;url=http://cnn.com");
    echo 
    'In 5 seconds you will be transferred to CNN';
    ?>

  • #15
    New to the CF scene
    Join Date
    Sep 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ilimrehberi



  •  

    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
    •