Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- session_start();
- include 'connection.php';
- $id=$_SESSION["id"];
- if (!isset($_SESSION['id'])) {
- header("location:login.php");
- }
- ?>
- <?php
- //DB Details
- $dbHost = 'localhost';
- $dbUsername = 'root';
- $dbPass = 'password';
- $dbName = 'images';
- //Create connection and select DB
- $db = new mysqli ($dbHost, $dbUsername, $dbPass, $dbName);
- if ($db->connect_error) {
- die ("Connection Failed: " . $db->connect_error);
- }
- //Get image data from database
- $result = $db->query("SELECT image From images Where user_id=$id");
- if ($result->num_rows > 0){
- $imgData = $result->fetch_assoc();
- header("Content-type: image/jpeg");
- echo $imgData['image'];
- }else{
- echo "Image not found...";
- }
- ?>
Add Comment
Please, Sign In to add comment