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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:23:06+00:00 2026-06-09T16:23:06+00:00

I need to be able to store the password submitted in a session, as

  • 0

I need to be able to store the password submitted in a session, as at present using the php_self method the page is just reloading as if the user has not entered the password correctly (this is happening in Firefox, it actually works fine with no session in Chrome / Safari) and so I believe a session is needed for it to work in FF, but I’m newish to PHP and not sure how I can go about this, here’s the code:

Thanks in advance

<?php
session_start();

$Password = 'hello';

   if (isset($_POST['submit_pwd'])){
      $pass = isset($_POST['passwd']) ? $_POST['passwd'] : '';


      if ($pass != $Password) {
         showForm("error", "WRONG PASSWORD");
         exit();     
      }
   } else {
      showForm();
      exit();
   }

function showForm($Inputclass="mister", $Placeholder="PLEASE ENTER PASSWORD"){ 

?>

With HTML:

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="pwd" id="pwd">


 <input class="<?php echo $Inputclass; ?>" name="passwd" type="password" size="79" style="margin-left: -100px;" placeholder="<?php echo $Placeholder; ?>"/>
         <br/>
             <input class="text" name="submit_pwd" value="Login" type="image" src="loginkey.png" style="position: relative; left: 240px; top: -35px;">

      </form>
  • 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-09T16:23:08+00:00Added an answer on June 9, 2026 at 4:23 pm

    If you hit the button, then $_POST[‘submit_pwd_x’] and $_POST[‘submit_pwd_y’] should be set, not $_POST[‘submit_pwd’]

    If you hit “enter” then $_POST[‘submit_pwd’], $_POST[‘submit_pwd_x’] or $_POST[‘submit_pwd_y’] should NOT be set – but sometimes are depending on the browser.

    You can’t rely on either, so your check if (isset($_POST[‘submit_pwd’])) will be unreliable

    The trick is to add a hidden field in the form, and check for sbmission of that hidden field in $_POST.


    More details on the answer (based on comment):

    PHP is

    if (isset($_POST['formsubmitted'])){ 
        ....
    }
    

    HTML is

    <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="pwd" id="pwd"> 
         <input class="<?php echo $Inputclass; ?>" name="passwd" type="password" size="79" style="margin-left: -100px;" placeholder="<?php echo $Placeholder; ?>"/> 
         <br/>
         <input type="hidden" name="formsubmitted" value="1" /> 
         <input class="text" name="submit_pwd" value="Login" type="image" src="loginkey.png" style="position: relative; left: 240px; top: -35px;"> 
    
    </form> 
    

    Edit:

    If you don’t click on the button (hit enter):

    • IE will send none
    • FF,Opera will send the submit_pwd_x=0 and submit_pwd_y=0
    • Chrome,Safari will send the submit_pwd_x=0, submit_pwd_y=0 and submit_pwd

    If you click the button:

    • IE will send submit_pwd_x=X and submit_pwd_y=Y
    • FF,Opera will send submit_pwd_x=X and submit_pwd_y=Y
    • Chrome,Safari will send the submit_pwd_x=X, submit_pwd_y=Y and submit_pwd
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Users of the website need to able to store images in their area ,
I need to be able to store the current height and width of a
I am currently writing a Employee store and I need to be able to
I need to be able to store data for a php application in a
I just created my first MVC webapp and noticed that I need to store
So I need to be able to actually decrypt the password because some old
I need to store my users' name/password somewhere (preferably the Registry) so my .Net
I need to store a password as an encrypted string in an XML file,
Need to be able to pull Magento products into an external template. Need to
I need to be able to access a list throughout my Rails project. For

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.