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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:34:26+00:00 2026-05-28T06:34:26+00:00

I am using a mysqli login system on my website for which the files

  • 0

I am using a mysqli login system on my website for which the files i have included here:

(login.php):

<?php
session_start();
require_once 'classes/Membership.php';
$membership = new Membership();

// If the user clicks the "Log Out" link on the index page.
if(isset($_GET['status']) && $_GET['status'] == 'loggedout') {
    $membership->log_User_Out();
}

// Did the user enter a password/username and click submit?
if($_POST && !empty($_POST['username']) && !empty($_POST['pwd'])) {
    $response = $membership->validate_User($_POST['username'], $_POST['pwd']);
}


?>



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

etc.

That is the main html file and the following are the php files:

(membership.php);

<?php

require 'Mysql.php';

class Membership {

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

        if($ensure_credentials) {
            $_SESSION['status'] = 'authorized';
proposed session variable:  $_SESSION['name'] = 'RESULT';
            header("location: index.php");
        } else return "Please enter a correct username and password";

    } 

    function log_User_Out() {
        if(isset($_SESSION['status'])) {
            unset($_SESSION['status']);

            if(isset($_COOKIE[session_name()])) 
                setcookie(session_name(), '', time() - 1000);
                session_destroy();
        }
    }

    function confirm_Member() {
        session_start();
        if($_SESSION['status'] !='authorized') header("location: login.php");
    }

}
?>

(mysql.php):

<?php

require_once 'includes/constants.php';

class Mysql {
    private $conn;

    function __construct() {
        $this->conn = new mysqli(DB_SERVER, DB_USER, DB_PASSWORD, DB_NAME) or 
                      die('There was a problem connecting to the database.');
    }

    function verify_Username_and_Pass($un, $pwd) {

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

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


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

    }
}

Right my query is I would like the server to echo the user’s Name in the index.php saying for example Hello: Jane Thompson an have the ability to use that name when they post anything to the database i.e: Posted By: Jane Thompson.

  • 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-28T06:34:26+00:00Added an answer on May 28, 2026 at 6:34 am

    you could save in $_SESSION the username and password like:

    if($_POST && !empty($_POST['username']) && !empty($_POST['pwd'])) {
        $response = $membership->validate_User($_POST['username'], $_POST['pwd']);
        $_SESSION['user'] = $_POST['username'];
    }
    

    so in index.php you could print

    <div>Name: <?php echo $_SESSION['user']?></div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

hello i want to make system website like yahoo messenger using PHP. here the
My problem in fairly simple. I have a login system constructed using php, mysql
I have a PHP authentication system on my website using the $_SESSION variable. A
I have a login form using jquery ajax and a php code. The issue
I have now changed my login system from session_register() to this: UPDATE : <?php
here is my scenario: I have a website with php, mySQL. I have a
I have been comissioned to make a website complete with a user login system
I would like to make a simple user login/registration system using PHP and mysql.
I already have an advanced user login/register system on my website ( colemansystems.psm2.co.uk ).
Hey This is my login script, using PHP5 and MYSQLi, I just had help

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.