I am trying to get user's information and show them in user's profile. And i found this query but it is in PDO and my work is in sqli here the query :

if(isset($_SESSION['user'])){

$getuser=$con->prepare("SELECT * From users where username=?");

$getuser->execute(array($sessionuser));

Sinfo=$getuser->fetch();
And here the whole code

<?php
 session_start();
   $sessionuser='';
   if(isset($_SESSION['user'])){
       $sessionuser=$_SESSION['user'];
   }  
   if(isset($_SESSION['user'])){
$getuser=$con->prepare("SELECT * From users where username=?");
$getuser->execute(array($sessionuser));
Sinfo=$getuser->fetch();
?>

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8" />
        <title></title>
    </head>
    <body>
        Username:<?php echo $info['username']?>
        Email:<?php echo $info['email']?>
        Register Date:<?php echo $info['reg_date']?>
        Password:<?php echo $info['password']?>
    </body>
</html>
<?php
   }else{
       header("Location: login.php");
   }
?>
AndreRet commented: PDO is the more secure way to go, maybe a good time now to move away... +14
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.