PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, January 19, 2022

[FIXED] php Session PHP getting data related to user

 January 19, 2022     php, phpmyadmin     No comments   

Issue

Anyway im trying to connect my database so that it will only show information related to the user, but no matter where i look or see for this information, its either outdated or not relevant to me. Could i get some help on trying to confirm the confirmation

<?php if (isset($_SESSION['username'])) : ?>
<t>
<p>Username: <strong><?php echo $_SESSION['username']; ?></strong></p>

<?php endif ?>

<?php

$query = "SELECT * FROM `confirm`;";
$result = mysqli_query($db, $query);
$resultCheck = mysqli_num_rows($result);

if ($resultCheck > 0) { 
while ($row = mysqli_fetch_assoc($result)) {
    echo $row['food'] , "<br>";
 }
}

?>

Solution

Of you want to fetch user specific information then you need to add a where clause in your sql query. Something like

$name=$_SESSION[‘username’]; 
$query = "SELECT * FROM `confirm` where name=‘$name’;";


Answered By - Parth Manaktala
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing