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

  • Home
  • SEARCH
  • 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 9274121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:16:51+00:00 2026-06-18T16:16:51+00:00

I am currently having problems with my login – the first attempt to login

  • 0

I am currently having problems with my login – the first attempt to login is always rejected but the second attempt succeeds. Any idea how I can resolve this?

login.php

if(isset($_POST['pmsubmit']))
    {
    LoginSubmit('pm', 'pmname', 'pmpass');
    }

    if (isset($_POST['tssubmit'])) {
    LoginSubmit('ts', 'dept', 'tspass');
    }

function LoginSubmit($pm_or_ts, $the_name_input, $the_pass_input)
{
  global $pdo;
    $salt = "$2a$12ehTk6%^jswam)*usnyruhst";
  $posted_name = $_POST[$the_name_input];
    $posted_pass = crypt($_POST[$the_pass_input], $salt);   
  // check if password matches the one in the table
  $query = $pdo->prepare("SELECT * FROM db_pass WHERE pass = :pass");
  $query->execute(array(":pass" => $posted_pass));
  // if there is a match then we log in the user
  if ($query->rowCount() > 0)
  {
    // session stuff
    $_SESSION[$the_name] = $posted_name;
      $_SESSION['id'] = $row['id'];
    // refresh page
    header( 'Location: ' . $pm_or_ts . '/index.php' ) ;
    exit;
  } 
  // if there is no match then we present the user with an error
  else
  { 
    echo '
    <script>
    $(function() {
        $( "#dialog-message" ).dialog({
      modal: true,
      buttons: {
        Ok: function() {
          $( this ).dialog( "close" );
            }
        }
        });
    });
    </script>
        <div id="dialog-message" title="Incorrect password">
        The password you have provided is incorrect.<br>Please try again.
    </div>
    ';
  }
}
?>

pm/index.php

<?php 
session_start();
setcookie("pmw", $_SESSION[$thename], time()+7200, '/');
require_once("../resources/php/connection.php");

if (empty($_SESSION[$thename]) || empty($_COOKIE['pmw']) ) {
    header("Location: ../login.php");
    exit;
}
?>

ts/index.php

<?php 
session_start();
setcookie("ts", $_SESSION[$thename], time()+7200, '/');
require_once("../resources/php/connection.php");

if (empty($_SESSION[$thename]) || empty($_COOKIE['ts']) ) {
    header("Location: ../login.php");
    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-18T16:16:52+00:00Added an answer on June 18, 2026 at 4:16 pm

    I think in you login.php you are not starting session and you are directly initializing the value to $_SESSION[$the_name] . So write session_start() at the beginning of the login.php file.

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

Sidebar

Related Questions

I'm trying to build firefox but I'm having some problems. I currently have Visual
I'm currently having problems to execute a command from a shell variable. In general
I am currently having problems with attempting to style the HTML rich text editor
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
Currently i am having some problems with getting some data out of a DataTable
I am currently making a facebook app and am having some problems with permissions.
Hi I am currently having a problem with parsing an Xml string without any
I am having problems closing out a C# windows form app. It will currently
I am currently having a problem with a UITableView, and more precisely with a
I'm currently having a problem with some Socket stuff. The output that I want

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.