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

SQLi and PDO have their favorable circumstances: PDO will take a shot at 12 diverse information base frameworks, though MySQLi will just work with MySQL information bases. Along these lines, on the off chance that you need to change your task to utilize another information base, PDO makes the cycle simple. ... Both are object-arranged, yet MySQLi likewise offers a procedural API.

Be a part of the DaniWeb community

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