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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:40:31+00:00 2026-06-14T20:40:31+00:00

I have a simple PHP login script that directs the user to dashboard.php if

  • 0

I have a simple PHP login script that directs the user to dashboard.php if the login is successful. Currently, all it is doing is refreshing the page.

    <?php 
if (isset($_POST["submit"])) {
    // startar sesion
    session_start(); 

// username and password
$userName = "user";
$password = "pass";
}

if (isset($_POST["userName"]) && isset($_POST["password"])) { 

    if ($_POST["userName"] == $userName && $_POST["password"] == $password) { 

    header( 'Location: dashboard.php' ) ; 
    } 
        // wrong login - message
        else {echo 'foo';} 
    }
    ?>
  • 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-14T20:40:32+00:00Added an answer on June 14, 2026 at 8:40 pm

    Try this

    <?php 
    
    session_start(); 
    
     // username and password
     $_SESSION['user'] = "user";
     $_SESSION['pass']= "pass";
    
    
    if (isset($_POST["userName"]) && isset($_POST["password"])) { 
    
    if ($_POST["userName"] == $_SESSION['user'] && $_POST["password"] ==    $_SESSION['pass']) { 
    
    header( 'Location: dashboard.php' ) ; 
    } 
        // wrong login - message
        else {echo 'foo';} 
    }
    ?>
    

    That just fixes your original code, however i would lean to more like this…

     <?
      session_start(); //always at the top of each page
    
      If empty($_SESSION){ header('location':'login.php')}
    
      else {header('location':'dashboard.php');
    

    Then you rewrite login to always assign session user and pass if the credentials have been verified authenticated

    Check post, if post exists compare to vals, if user password match, write them respective to their session array nodes, the redirect to dashboard which should also have thatfunctionality i outlined above at the top of its page to check session

    Also do not store the users password in the session, just the verified user name should suffice and keep your site clean from potential intruders hacking in and stealing passwords of others

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

Sidebar

Related Questions

I have a very simple login/user registration script that stores passwords using sha1 and
I have my simple jquery & php reg/login script working. Basically if the user's
I have a simple php script on my domain that sends me an email:
I have a simple PHP script that will either serve up a streaming ASF
I have a simple php page that displays data from a mysql database. I
I have a simple PHP script that is supposed to redirect to another document
I currently have a website that allows my visitors to login via a simple
I have php login script that I have modified with htm tables and css.
I have this simple login script: $.ajax({ type: 'POST', url: 'authorize.php', data: { username:
I have simple php validation form that is halfway working. If you leave the

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.