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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:25:43+00:00 2026-06-10T14:25:43+00:00

Here’s a simple username/password login form. When I submit with correct data it goes

  • 0

Here’s a simple username/password login form. When I submit with correct data it goes to test.php and echos ‘hi’ . But if I hit refresh on test.php it shows No Permission. How can I make it show ‘hi’ on test.php after refreshing test.php after I submit?

login.php:

<?php
    session_start();
    session_unset();
?>

<html>
    <body>
        <?php include 'header.php'; ?> 
        <form action = "test.php" method = "post">
            <br/>
            Enter username
            <input type = "text" name = "user"/>
            <br/>
            Enter passowrd
            <input type = "password" name = "pass"/>
            </br>
            <input type = "submit" value = "submit" name = "submit"/>
        </form>
    </body>
</html>

test.php:

<?php
    session_cache_limiter('private_no_expire');
    session_start();
    $_SESSION['authuser'] = 0;

    if(isset($_POST['user']) && isset($_POST['pass']))
    {
        $_SESSION['username'] = $_POST['user'];
        $_SESSION['userpass'] = $_POST['pass'];
    }
    else
    {
        $_SESSION['username'] = NULL;
        $_SESSION['userpass'] = NULL;
    }

    if($_SESSION['username']=="joe" && $_SESSION['userpass'] == 123456)
    {
        $_SESSION['authuser']=1;
        echo 'hi';
    }
    else
    {
        echo "No permission";
        exit();
    }
?>
  • 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-10T14:25:45+00:00Added an answer on June 10, 2026 at 2:25 pm

    When you refresh, your browser should give you the option to repost the values, if you click yes it should work.

    Or you could remove the else part of the code:

    else
    {
        $_SESSION['username'] = NULL;
        $_SESSION['userpass'] = NULL;
    }
    

    If you remove that then the session variables will be remembered and the rest of your code will use those session values.

    EDIT:

    On first load of that page (with my suggested change above), without having logged in before, you would get the undefined index error. To solve this you could change the line:

    if($_SESSION['username']=="joe" && $_SESSION['userpass'] == 123456)
    

    to

    if(isset($_SESSION['username']) && $_SESSION['username']=="joe" && isset($_SESSION['userpass']) && $_SESSION['userpass'] == 123456)
    

    This will check the username and userpass are set, before checking their values.

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

Sidebar

Related Questions

Here's the code I'm running. Basically I scrape data, and place them into simple
Here is what is probably a simple question, but I wasn't able to find
Here is the code: create table `team`.`User`( `UserID` bigint NOT NULL AUTO_INCREMENT , `Username`
Here is what I am currently doing. PHP echo's out the recent post in
Here is a simple timepicker to jQuery UI's datepicker <script type=text/javascript> /* <![CDATA[ */
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here is what I am trying to achieve in PHP: I have this string:
Here is my simplified data structure: Object1.h template <class T> class Object1 { private:
Here a simple question : What do you think of code which use try
Here's what I'm trying to do... It's quite simple and obviously there must be

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.