Alter profile picture using <img> tag and PHP

108 views Asked by At

I'm still new on php. I'm currently building a website which a user can upload an image to change their profile picture.

The file of image will we insert into table user, row image location on database and directory "upload". The formatting is like abc.jpeg

My code for the <img> tag, which is where I display the profile image. But the image does not appear. Only the thumbnail image is displayed and not the exact image.

<img src=<?php 
    $current = $fgmembersite->UserEmail();
    if ($handle = opendir('upload/')) {
        $sql = "SELECT image_location FROM user WHERE email='$current'";
        //$file = mysql_real_escape_string($sql);
        if ((file_exists('upload/'.$sql) == $sql)) {
            echo 'upload/'.$sql.'.png';
        } else if (file_exists('upload/'.$sql)) {
            echo 'upload/'.$sql.'.jpg';
        }
    }
    closedir($handle);
?> alt="">

If you don't mind, can you check my code and see where I went wrong? Thank you for your helping.

0

There are 0 answers