Post: Displaying User Information From Database PHP - By Crxsho
02-20-2017, 10:16 PM #1
IcarusXSEC
Do a barrel roll!
(adsbygoogle = window.adsbygoogle || []).push({}); Displaying Database Information Of Current Logged in User Tutorial 1

This is My First PHP Tutorial so i hope it helps all you beginners out there

How to Show a Users Information from Database

To Show a Users information from a row all you have to do is Select the Row Where the Users ID is In A query, then Fetch all The Columns

    
<?php

$user = new USER();

$user_id = $_SESSION['user_session'];

$stmt = $user>runQuery("SELECT * FROM user WHERE user_id=:user_id");
$stmt->execute(array(":user_id"=>$user_id));

$userRow=$stmt->fetch(PDO::FETCH_ASSOC);
?>

<h1>Welcome Back ! <?php print($userRow['username']); ?></h1>




Im Using the column name username as an example
You Would replace this with the name of the column with information you would like to show

This Would Output

Welcome Back! Crxsho

I will be posting more PHP Tutorials like this because i see that this Part of the Forum isn't That active
Thank you and i hope this Helps People Creating websites

By Crxsho or (pumahmodzuk)
02-24-2017, 12:53 PM #2
EpsilonDev
Maggbot timeout!
I guess.
Or

$query = $this->db->prepare("SELECT * FROM users WHERE `id` = :id");
$query->execute(array("id"=>$_SESSION['id']));
$res = $query->fetch(PDO::FETCH_ASSOC);
return $res[$column];

Depending how you have your shit set up
02-27-2017, 07:08 PM #3
IcarusXSEC
Do a barrel roll!
Originally posted by x View Post
I guess.
Or

$query = $this->db->prepare("SELECT * FROM users WHERE `id` = :id");
$query->execute(array("id"=>$_SESSION['id']));
$res = $query->fetch(PDO::FETCH_ASSOC);
return $res[$column];

Depending how you have your shit set up


I Have a Functions php file thats how mines setup
03-01-2017, 05:43 AM #4
Passion
League Champion
Stop

using
fucking
procedural

The following user thanked Passion for this useful post:

Jelly
03-01-2017, 05:49 AM #5
Originally posted by Passion View Post
Stop

using
fucking
procedural


whyyy
03-01-2017, 05:52 AM #6
Passion
League Champion
Originally posted by John View Post
whyyy


we've had this conversation before john1337hax i will not allow anyone to write procedural code anymore

anyone caught doing so will get perm banned
03-01-2017, 06:11 AM #7
oh...sorry, wont happen again
03-01-2017, 11:07 AM #8
IcarusXSEC
Do a barrel roll!
Im Confused
03-04-2017, 03:07 AM #9
Default Avatar
Oneup
Guest
Originally posted by John View Post
oh...sorry, wont happen again


He has no power here much like his real life so don't worry about him. He's just a skid
03-12-2017, 08:16 PM #10
Default Avatar
Oneup
Guest
Originally posted by Passion View Post
shut up you virgin loser, you visit this site daily lmao


Yet here you are?

Copyright © 2024, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo