Note that there are some explanatory texts on larger screens.

plurals
  1. PODisplay username once user has logged in
    primarykey
    data
    text
    <p>Hello i am try to display the username after they log in.</p> <p>here is my code</p> <p>This is the page i would like to show it. index.php</p> <pre><code>&lt;?php require_once 'classes/Membership.php'; $membership = New Membership(); $membership-&gt;confirm_Member(); ?&gt; &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8" /&gt; &lt;title&gt;Home Page&lt;/title&gt; &lt;link href="css/me.css" rel="stylesheet" type="text/css" /&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="top"&gt; &lt;/div&gt; &lt;div id="top-register"&gt; &lt;? $_SESSION['username'] ?&gt; &lt;a href="login.php?status=loggedout"&gt; Log Out &lt;/a&gt; &lt;/div&gt; &lt;div id="top-login"&gt; &lt;a href="index.php"&gt; &lt;/a&gt; &lt;/div&gt; &lt;div id="line"&gt; &lt;div id="banner-text"&gt; Testing &lt;/div&gt; &lt;div id="banner"&gt; &lt;/div&gt; &lt;/div&gt; &lt;center&gt; &lt;div id="plan"&gt; &lt;div id="plan-innder"&gt; &lt;a href="index.php"&gt;&lt;img src="images/plan/starter.png" alt="Starter" width="250" height="300" /&gt;&lt;/a&gt; &lt;a href="index.php"&gt;&lt;img src="images/plan/regular.png" alt="Regular" width="250" height="300" /&gt;&lt;/a&gt; &lt;a href="index.php"&gt;&lt;img src="images/plan/advanced.png" alt="Advanced" width="250" height="300" /&gt;&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; enter code here &lt;/center&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>The workings membership.php</p> <pre><code>&lt;?php require 'Mysql.php'; class Membership { function validate_user($un, $pwd) { $mysql = New Mysql(); $ensure_credentials = $mysql-&gt;verify_Username_and_Pass($un, md5($pwd)); if($ensure_credentials) { $_SESSION['status'] = 'authorized'; 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"); } } </code></pre> <p>Mysql.php</p> <p>This is what is connecting to the data base.<br> <pre><code>require_once 'includes/constants.php'; class Mysql { private $conn; function __construct() { $this-&gt;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 users WHERE username = ? AND password = ? LIMIT 1"; if($stmt = $this-&gt;conn-&gt;prepare($query)) { $stmt-&gt;bind_param('ss', $un, $pwd); $stmt-&gt;execute(); if($stmt-&gt;fetch()) { $stmt-&gt;close(); return true; } } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload