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 6676093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:56:38+00:00 2026-05-26T03:56:38+00:00

So I have a home page where a user can log in. Once they

  • 0

So I have a home page where a user can log in. Once they log in I need them to redirect them to index.php that just pulls there information. The Jquery makes a call to index.php where it runs a check against Mysql, if the user doesn’t exist it alerts not a valid user. Now if it does I need to send them back to index.php.
Hers is index.php

    <?php
    include_once 'includes/membersclass.php';
    session_start();
    $member = new MEMBERS();

    if(!isset($_SESSION['id'])) {
        if($_POST['action'] == true) {
            $result = $member->login($_POST);
            if($result) {
                $_SESSION['id'] = $result;
                echo $_SESSION['id'];
            } else {
                 return false;
            }
        } 

        if($_POST['signup'] == 'true') {
            $result = $member->signup($_POST);
            if($result) {
                $_SESSION['id'] = $result;
            } else {
                header("Location: root.php");
            }
        } 
    }
?>

<!DOCTYPE html>
<html>
    <head>
        <title></title>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel='stylesheet' type='text/css' href='css/members.css' />
    </head>
    <body>
        <div id="calendar_container">
            <?php $member->drawCalendar(2, 2011); echo $_SESSION['id']; ?>
        </div>
    </body>
    </html>

As you can see Jquery makes the initial call to index.php with a post and get the response back. I set the session to store the user id. On the same page is where the users profile will show. How do I get back here on successful login. Am I even doing it right, should this be separate from the PHP to begin with. Uggghhh, please help.

  • 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-26T03:56:38+00:00Added an answer on May 26, 2026 at 3:56 am

    The question is a bit vague, but if I understand correctly you want to reload the index.php page after a successful login.

    if(!isset($_SESSION['id'])) {
        if($_POST['action'] == true) {
            $result = $member->login($_POST);
            if($result) {
                $_SESSION['id'] = $result;
                echo $_SESSION['id'];
            } else {
                 return false;
            }
        } 
    

    If I’m not mistaken, this piece of code checks if user is already logged in. If not, your checking if the previous Jquery page has given either an ‘action’ (which I assume is a login call) or a ‘signup’ (which I assume is to create a new account).

    In this case, if ‘action’ is chosen, you check if the user exists ($result = $member->login($_POST);) and if he does, you create the session ID, and the index-page should show the profile.

    Since the $_SESSION[‘id’] has only been assigned after the page has loaded, it does not check if the $_SESSION[‘id’] has been assigned again. So you have to reload the page to do this:

    if(!isset($_SESSION['id'])) {
        if($_POST['action'] == true) {
            $result = $member->login($_POST);
            if($result) {
                $_SESSION['id'] = $result;
                echo $_SESSION['id'];
                header("Location: index.php");
    
            } else {
                 return false;
            }
        } 
    

    Now it will call the index.php again, it goes past the if(!isset($_SESSION[‘id’])) part, since this time the session is created, and to the code (which is not yet present here?) that will take care of the profile.

    I have to assume quite a bit here, but tell me how close I am.

    PS:

    if($_POST['action'] == true)
    

    and:

    if($_POST['signup'] == 'true')
    

    Once you have true without quotes, once with. I think you just want to check which one is set? This will suffice:

    if(isset($_POST['signup']))
    

    and

    if(isset($_POST['action']))
    

    Makes the code more consistent and less prone to errors.

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

Sidebar

Related Questions

I have a home page that contains a texfield that reads the user input,
In my application I have a login page were the user can log in.
I have an ASP.NET home page where user provides his login ID. Depending on
Assuming that we have: http.HandleFunc(/smth, smthPage) http.HandleFunc(/, homePage) User sees a plain 404 page
On my home page i have roughly 10 grids that sit inside ajax tabs
I have an aspx page, which is a User Log-In area. I want to
I have an admin page (../index2.php) I would like to log in as my
I have a log in page which is the home page so is located
On my homepage I have a simple search form. The user can enter some
I have a home page with ul li div the div is a square

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.