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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:15:36+00:00 2026-06-05T09:15:36+00:00

I have my login.php set up so that whenever a login is successful, it

  • 0

I have my login.php set up so that whenever a login is successful, it automatically directs to profile.php. However, even if the login is successful, whenever I go to profile.php it still says “You must be logged in to access this page”. Why?

Here’s my login.php:

$email = $_POST['email-field'];
$password = $_POST['password-field'];

if ($email && $password)
{
    $connect = mysql_connect("xx", "xx", "xx") or die("Couldnt connect!");
    mysql_select_db(xx) or die("Couldnt find db");

    $query = mysql_query("SELECT * FROM users WHERE email = '$email'");

    $numrows = mysql_num_rows($query);

    if ($numrows != 0)
    {

        while ($row = mysql_fetch_assoc($query))
        {
            $email = $row['email'];
            $md5password = $row['password'];
        }

        if ($email == $email && $md5password == md5($password))
        {
            header("Location: profile.php");
            $_SESSION['email']==$email;
        }
        else
            echo "Incorrect password";
    }
    else
        die("That user doessnt exist!");
}
else
    die("Please enter a username and a password");

And my profile.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<?php 

include('get-info.php');

session_start();

if ($_SESSION['email'])
    echo "<a href=logout.php>Logout</a>";
else
    die("You must be logged in to access this page");


?>


<html>

    <head>

        <title>

            R-A | Profile

        </title>

        <link href='css.css' rel='stylesheet' type='text/css' />

    </head>

    <body class='body3' >

        <div class='logo-bar'>

            <div class='menu'>

                <img src='images/rateaway.png' class='logo-bar-img' />

                    <div class='menu-options'>

                        <a href='index.php' class='menu-links' >Home</a>

                        <a href='profile.php' class='menu-links' >Profile</a>

                        <a href='profile.php' class='menu-links' >Friends</a>

                    </div>

            </div>

        </div>

        <div class='profile-main-content' >

            <div class='profile-current-info'>

                <p class='profile-name'> <?php get_info('iran_mateu@yahoo.com', 'name'); ?> </p>

                <img src='<?php get_info('iran_mateu@yahoo.com', 'profilepic'); ?>' class='profile-pic'/>

                <p class='profile-dob' > Born: <?php get_info('iran_mateu@yahoo.com', 'dob'); ?> </p>

                <p class='profile-country' > Currently lives in: <?php get_info('iran_mateu@yahoo.com', 'country'); ?> </p>

                <p class='profile-gender' > Gender: <?php get_info('iran_mateu@yahoo.com', 'gender'); ?> </p>

            </div>

            <div class='profile-edit-info' >



            </div>

        </div>

    </body>
  • 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-06-05T09:15:36+00:00Added an answer on June 5, 2026 at 9:15 am

    You are not writing to the session after a successful login. Consider this part:

    if ($email==$email&&$md5password==md5($password))
        {
            header("Location: profile.php");
            $_SESSION['email']==$email;
        }
    

    You should be using = instead of ==. Since you are not, you are not assigning $email to $_SESSION['email']. You’re not assigning anything, just doing a comparison (and discarding its return value). So it should be:

    $_SESSION['email'] = $email;
    

    Also, you should add session_start(); to the top of login.php, as minitech suggested on his answer.

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

Sidebar

Related Questions

I have 3 pages in my set up here: login.php: The login page that
I have a login setup on a site that stores login information in PHP's
I have a php file that holds my login details named connect.php. $host =
I have php scripts that do things like register, login, upload. I would like
I have a simple chat client set up that allows users to login with
I have a PHP login which sets 2 cookies once someone login. The problem
I have an php website with login form and I want every visitors can
i have created a forum using php/mysql and users login through facebook using php
I have just finished creating an entire login and register systsem in PHP, but
I have a database system developed in mysql and php, with a login system

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.