How to make a profile image

Hey guys!

I have been following a tutorial on how to build a profile image from mmtuts and almost got it to work. If I changed the database to 0, then the picture image does change but I just can’t get the following code to update the query and it seems correct to me…

<?php
session_start();
include_once 'dbh.php';
$id = $_SESSION['u_id'];
$status = 0;

if (isset($_POST['submit'])) {
	$file = $_FILES['file'];

	$fileName = $_FILES['file']['name'];
	$fileTmpName = $_FILES['file']['tmp_name'];
	$fileSize = $_FILES['file']['size'];
	$fileError = $_FILES['file']['error'];
	$fileType = $_FILES['file']['type'];

	$fileExt = explode('.', $fileName);
	$fileActualExt = strtolower(end($fileExt));

	$allowed = array('jpg', 'jpeg', 'png', 'pdf');

	if (in_array($fileActualExt, $allowed)) {
		if ($fileError === 0) {
           if ($fileSize < 1000000) {
              $fileNameNew = "profile".$id.".".$fileActualExt;
              $fileDestination = 'uploads/'.$fileNameNew;
              move_uploaded_file($fileTmpName, $fileDestination);
              $sql = "UPDATE profileimg SET status = ? WHERE userid = ?;";

              $stmt = mysqli_stmt_init($conn);
              if (!mysqli_prepare($stmt, $sql)) {
              	 echo 'SQL error';
              } else {
              	mysqli_stmt_bind_param($stmt, "ii", $status, $id);
              	mysqli_stmt_execute($stmt);
              }
              header("Location: ../index.php?uploadsuccess");
           } else {
           	   echo "Your file is too big!";
           }
		} else {
			echo "There was an error uploading your file!";
		}
	} else {
		echo "You cannot upload files of this type!";
	}
}

Try replacing the above by

$sql = "UPDATE `profileimg` SET `status`=? WHERE `userid`=?";

My apologies… It was my mistake as I forgot to add stmt in if (!mysqli_stmt_prepare) but now my profile picture is really hugh… If I have no idea which picture the user will upload, how can i add a class to it so that I can style it? Also, would I do something like this to shrink it? It is taking up half of the page…

I have added a class here…

if ($rowImg[‘status’] == 0) {
echo “”;
} else {
echo “”;
}

and have done something liked this in my CSS code:

.profile_picture {
width: 300px;
height: 200px
}

but it hasn’t changed anything…I just noticed that the format doesn’t look right on the right screen…it doesn’t show my code for my echo part…

if I add a width and height here , then it does work…

if ($rowImg[‘status’] == 0) {
echo “”;
} else {
echo “”;
}

Try adding px next to the width and height: e.g width="100px"