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

  • Home
  • SEARCH
  • 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 967927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:23:52+00:00 2026-05-16T02:23:52+00:00

I am making a registration system with an e-mail verifier. Your typical use this

  • 0

I am making a registration system with an e-mail verifier. Your typical “use this code to verify” type of thing.

I want a session variable to be stored, so that when people complete their account registration on the registration page and somehow navigate back to the page on accident, it reminds them that they need to activate their account before use.

What makes this problem so hard to diagnose is that I have used many other session variables in similar ways, but this one is not working at all. Here’s my approach:

/* This is placed after the mail script and account creation within the same if 
statement. Things get executed after it, so I know it's placed correctly. */

$_SESSION['registrationComplete'] = TRUE; 

// I've tried integer 1 and 'Yes' as alternatives.

Now to check for the variable, I placed this at the top of the page.

echo $_SESSION['registrationComplete']; // To see if it's setting. This gives the
                                        // undefined index notice.

if (isset($_SESSION['registrationComplete'])) {

// Alternatively, I have nested another if that simply tests if it's TRUE.

    echo $_SESSION['registrationComplete']; // When echo'd here, it displays nothing.

    echo '<p>Congratulations, Foo! Go to *link to Bar*.</p>';

}

Now, I used to have the page redirect to a new page, but I took that out to test it. When the page reloads from submit, my message in the if statement above appears and then I get an Notice: Undefined index: registrationComplete blah blah from the echoing of the session var!

Then if I ever go back to the page, it ignores the if statement all together.

I have tested for typos and everything, clearing session variables in case old ones from testing were interfering, but I am having no luck. A lot of Googling just shows people suppressing these errors, but that sounds insane! Not only that, but I am not getting the same persistence of session variables elsewhere on my site. Can someone point out if I’m doing something blatantly wrong? Help! Thanks!

FYI, I read several related questions and I am also a beginner, so I may not know how to utilize certain advice without explanation.

As requested, more code, heavily annotated to keep it brief

var_dump($_SESSION);

// It's here to analyze that index message. I guess it's not important.
echo $_SESSION['registrationComplete']; 

if (isset($_SESSION['registrationComplete'])) { 

    // The golden ticket! This is what I want to appear so badly.
    echo 'Congratulations, Foo! Go to *link to Bar*.';

}


// Explanation: I don't want logged in users registering. 
// The else statement basically executes the main chunk of code.

if (isset($_SESSION['user_id'])) {

    echo 'You are logged in as someone already.';

}

else {

    if (isset($_POST['submitRegister'])) {

        // Code: Database connection and parsing variables from the form.

        if (!empty($email) && !empty($email2) && $email == $email2 && !empty($displayName) && !empty($password) && !empty($password2) && $password == $password2) {

            // Code: Query to retrieve data for comparison.

            if (mysqli_num_rows($registrationData) == 0) {

                // Code: Generates the salt and verification code.

                // Code: Password hashing and sending data to verify database.

                // E-mail the verification code.

                $_SESSION['registrationComplete'] = 'yes';

            }

            else {

                // Some error handling is here.
                $registerError = 'The e-mail address you entered is already in use.';

            }

        }

        // the elseif, elseif, and else are more error handling.

        elseif ($email != $email2) { $registerError = 'Your e-mails did not match'; }

        elseif ($password != $password2) { $registerError = 'Passwords didn\'t match.'; }

        else { $registerError = 'Filled out completely?'; }

        // If the registration was submitted, but had errors, this will print the form again.

        if (!isset($_SESSION['registrationComplete'])) { require_once REF_DIR . REF_REGISTERFORM; }


        // IMPORTANT! it turns out my code did not work, I forgot I had the same statement elsewhere.
        else { echo 'Congratulations, Foo! Go to *link to Bar*.'; }
    }

    // Creates form.

    else { require_once REF_DIR . REF_REGISTERFORM; }

}
  • 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-16T02:23:52+00:00Added an answer on May 16, 2026 at 2:23 am

    This came down to the basics of debugging/troubleshooting.

    1. Understand as much as you can about the technique/library/function/whatever that you’re trying to use.
    2. Inspect the salient bits and make sure that they are what you expect or what they should be. (There’s a slight difference between those two, depending on the situation.)
    3. If that doesn’t bring you towards a solution, step back and make sure you’re understanding the situation. This may mean simplifying things so that you’re only dealing with the issue at hand, i.e. create a separate, simpler test case which exposes the same problem. Or, it may simply mean that you stop coding and work through the flow of your code to make sure it is really doing what you think it is doing.

    A typical issue with sessions not working is forgetting to use session_start() (near or at the top) of any page which uses sessions.

    One of my favorite snippets of PHP code, for debugging:

    print '<pre>';
    var_dump($some_variable);
    print '</pre>';
    

    I try to use print for debugging and echo for regular output. It makes it easier to spot debugging code, once it’s goes beyond a few trivial bits of output.

    Meanwhile, var_dump will print a bit more info about the variable, like it’s type and size. It’s important to wrap it in <pre></pre> so that it’s easier to read the output.

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

Sidebar

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.