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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:34:29+00:00 2026-05-19T09:34:29+00:00

at the moment, i’m taking POST information from a form and passing it to

  • 0

at the moment, i’m taking POST information from a form and passing it to a login.php page which runs them through this function:

function verify_Username_and_Pass($un, $pwd) {

    $query = "SELECT *
            FROM users
            WHERE username = ? AND password = ?
            LIMIT 1";

    if($stmt = $this->conn->prepare($query)) {
        $stmt->bind_param('ss', $un, $pwd);
        $stmt->execute();

        if($stmt->fetch()) {
            $stmt->close();
            return true;
        }
    }

}

At the moment, the only thing this checks for is whether a matching record exists, which in turn redirects the user to secret.php with this:

function validate_user($un, $pwd) {
    $mysql = New Mysql();
    $ensure_credentials = $mysql->verify_Username_and_Pass($un, $pwd);

    if($ensure_credentials) {
        $_SESSION['status'] = 'authorized';
        header("location: ../secret.php");
    } else {
        header("location: ../index.php");
    }

} 

But what i need to do is, instead of one secret page, have a PHP page for each user in the DB (theres only going to be a couple) so i need the function to return the name of the username if successful and redirect them to [username].php and also set a session with the username in it, so on the secret pages i can check whether the right user is coming to the right page? That make sense?

  • 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-05-19T09:34:30+00:00Added an answer on May 19, 2026 at 9:34 am
    function validate_user($un, $pwd) {
        $mysql = New Mysql();
        $ensure_credentials = $mysql->verify_Username_and_Pass($un, $pwd);
    
        if($ensure_credentials) {
            $_SESSION['status'] = 'authorized';
            $_SESSION['username'] = $un;
            header("location: ../secret.php");
        } else {
            header("location: ../index.php");
        }
    
    } 
    

    secret.php

    <?php
    session_start(); //important;
    
    if($_SESSION['status'] != 'authorized') { 
        header("Location: ../index.php");  // not logged in
    }
    
    /* user specific stuff.. */
    echo '<h1>' . $_SESSION['username'] . '</h1>';
    
    $query = 'SELECT * FROM `user_profile` WHERE `username`="' . $_SESSION['username'] . '"';
    //etc
    

    edit
    if you’re insisting on having specific pages, have something like this:

    inside ross.php

    <?php
    session_start();
    if($_SESSION['username'] != 'Ross') { die('you shouldn\'t be here..'); }
    
    // ok it's Ross, carry on
    ?>
    

    probably all better done using DB + sessions

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

Sidebar

Related Questions

At the moment I am trying to validate a form using PHP. The problem
At the moment I pass values from one page to another. I need to
At the moment my code (PHP) has too many SQL queries in it. eg...
At the moment I use PHP for almost everything I develop for the Web
At the moment I have a set of divs, generated dynamically by php and
At the moment I have about 2000 trades which are priced using excel. I
Having a duh moment trying to implement a new content page Here's the structure
At the moment I have a widget which, when the user clicks on it,
Big discussions in the moment at our company. How to handle updates to PHP
At the moment, my android widget runs a PendingIntent when you click it. 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.