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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:15:25+00:00 2026-06-15T02:15:25+00:00

After a successful login (i.e when user clicks the login button after entering the

  • 0

After a successful login (i.e when user clicks the login button after entering the username and password), based on the user type I want to send user to a specific page. Below is my code. (Here, if usertype is ’employee’, he should be taken to “data-update.php” page after clicking ‘login’ button.)

This is the code in the index.php page:

// This file is the home page.

// Require the configuration before any PHP code as the configuration controls error reporting:
require ('config.inc.php');

// The config file also starts the session.

// Require the database connection:
require (MYSQL);

// If it's a POST request, handle the login attempt:
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    include ('login.inc.php');
}

/* PAGE CONTENT STARTS HERE! */
?>
<!DOCTYPE html>
<html lang="en">
<head>
...

This is the code in the login.inc.php page:

<?php 

// This is the login page for the site.
// It's included by index.php, which receives the login form data.

// Array for recording errors:
$login_errors = array();

// Validate the username:


// Validate the password:


if (empty($login_errors)) { // OK to proceed!

// Query the database:
$q = "SELECT id, type FROM users WHERE (username='$u' AND pass='"  .  get_password_hash($p) .  "')";        
$r = mysqli_query ($dbc, $q);

if (mysqli_num_rows($r) == 1) { // A match was made.

    // Get the data:
    $row = mysqli_fetch_array ($r, MYSQLI_NUM); 

    // Store the data in a session:
    $_SESSION['user_id'] = $row[0];
    $_SESSION['username'] = $u;     

    if ($row[1] == 'employee') {
        reset_sms_update_session();
        header("Location: http://".BASE_URL."data-update.php");                         
        exit;
    }
    elseif ($row[1] == 'client'){
        header("Location: http://".BASE_URL."About.html");
        exit;
    }

...

And this is a partial code in “data-update.php” page:

 // Start the session:
 session_start();

function redirect_invalid_user($check = 'user_id', $destination = 'index.php', $protocol = 'http://') {

// Check for the session item:
if (!isset($_SESSION[$check])) {
    $url = $protocol . BASE_URL . $destination; // Define the URL.
    header("Location: $url");
    exit(); // Quit the script.
}

} // End of redirect_invalid_user() function.

//Redirect to index.php if user not logged in
redirect_invalid_user( );

/* PAGE CONTENT STARTS HERE! */
?>
<!DOCTYPE html>

...

The problem is that, in Google Chrome when user clicks the login button, he is first taken to the index.php page (where the redirection occurs) and then he has to click login button again to be taken to “data-update.php” page.
Why is this happening in Google Chrome?
(FYI: this does not happen in XAMP testing environment in my local PC.)

This does NOT happen in Firefox or IE8 (i.e. user is taken to “data-update.php” first time login button is clicked).

Please help.

  • 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-15T02:15:26+00:00Added an answer on June 15, 2026 at 2:15 am

    I solved this by setting a permanent redirect from CPanel in my webserver for http://example.com to http://www.example.com.

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

Sidebar

Related Questions

Currently after successful login I add md5($username) md5($password) in cookies and then every time
Suppose a user inputs his/her username and password and clicks on the submit button,
After a successful login via Devise, how can I redirect the user back to
I am successfully redirecting user after Login to a page called CustomerStart. After that
My question of the day is this. After a successful login I want to
I am trying to implement a functionality so that user after a successful Login
Im trying to test my successfully creates a new user after login (using authlogic).
After successful setup on initial launch of MySQL, the page prompted me to set
Hi I have a Sticky form that after successful completion I want to clear
After successfully acquiring an oauth_token for a user, I am able to get successful

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.