Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7537091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:45:16+00:00 2026-05-30T06:45:16+00:00

1: i use register.php to sign up the clients, 2: the data collected from

  • 0

1: i use register.php to sign up the clients,

2: the data collected from the form is send to 1.php, it is saved in database

3: after form data is saved in database, 1.php forwards selected form data (myValue) to register.php?myValue=’abc’

in 1.php, i am saving a session variable like this

@session_start();
$_SESSION['color']='blue';

the code of register.php is

 if (isset($_SESSION['color'])) {
            header('Location: http://mydomain.com/thankyou.php');
    }
 else {


@session_start(); 
some other stuff  that was initially use for signing up the clients

my logic is to check for session variable and to redirect it to some-other page

when step 1 , step 2 and step 3 are complete, page should be
redirected to thankyou.php

currently, when step 1, step 2, step 3 are done, instead of opening thankyou.php, the following page is being opened

http://mydomain.com/register.php?myValue='abc'

however, if i re-open register.php or go back to step one (opening register.php), thankyou.php is displayed…

can somebody guide me where i am doing the blunder? why redirection is not being successful although session variables are being created?

code Update

i tried the following code at the top of my register.php

@session_start();


   if (isset($_SESSION['color'])) {
            header('Location:http://mydomain.com/thankyou.php');
            exit;
    }
 else{
remaining stuff

it occasionally do the trick, redirects to the page, while on occasion (greater in number), it fails in redirecting to thankyou.php,, also the code needs to delete complete history and cache to work (after doing so, still miss hits occurs..)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T06:45:18+00:00Added an answer on May 30, 2026 at 6:45 am

    In your register.php, you can’t test for the session variable before you issue the session_start, so your code should be more like:

    session_start(); 
     if (isset($_SESSION['color'])) {
                header('Location: http://mydomain.com/thankyou.php');
        }
     else {
     // Something else....
    

    EDIT:

    Another thing I’ve found useful when trying to set session variable in conjunction with redirects is to proceed to the redirect only after running a function. Here’s how it would work:

    $throwAwayVariable = setColor('blue');
    if($throwAwayVariable ){  // separated out into a function so it wouldn't redirect before the session variable was saved
        session_write_close();
        header("Location: http://mydomain.com/thankyou.php");
    }
    
    function setColor($color){
        @session_start();
        $_SESSION['color']='blue';
        return true;
    }
    

    Since not all your code is posted, you’ll have to figure out where this goes, but I’ve always had my session vars work after this process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've set up a basic html/php submission form where people can register for our
Desperately trying to enable a widget from functions.php file... When I use it as
I'm attempting to use AJAX to insert data into a database, but am unable
I am attempting to use JSONP to return an array from PHP to JavaScript.
When should I use ScriptManager to register scripts and when is it ok to
I have a .NET user control registered as COM. I use regasm to register
I am trying to use Autofac and Autofac.Integrations.Web to register ASP.NET MVC controllers. I
I'm trying to use .NET HttpListener in a C# project. When I register my
I have the following php code: index.php <?php spl_autoload_extensions(.php); spl_autoload_register(); use modules\standard as std;
I'm trying to use facebook connect in my site so users can register/login with

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.