title: How to show users profile picture
body: <p>I want to show my users profile picture when the sign in . When they click the <code>change profile picture</code> button, their picture gets saved into the directory and then the database . I don't know where to start. How do I show whatever picture the user has, as their profile picture ?</p>
  
  <p>profile.php:</p>
  
  <pre><code>&lt;form id="form2" action="upload.php" method="post" enctype="multipart/form-data"&gt;
  &lt;p id="p1"&gt;Change profile picture:&lt;/p&gt; &lt;br /&gt;
  &lt;input type="file" name="fileToUpload" id="fileToUpload"&gt;&lt;br /&gt;
  &lt;br&gt;&lt;input id="sub1" type="submit" value="Change profile picture" name="change"&gt;&lt;br /&gt;
  &lt;/form&gt;
  
  &lt;!-- Trigger the Modal --&gt;
  &lt;img id="myImg" src="default.jpg" width="200" height="150"&gt;
  </code></pre>
  
  <p>EDIT!!!!</p>
  
  <pre><code>&lt;?php
  $username = $_SESSION['username'];
  
  if(isset($_FILES['image'])){
  $errors= array();
  $file_name = $_FILES['image']['name'];
  $file_size = $_FILES['image']['size'];
  $file_tmp = $_FILES['image']['tmp_name'];
  $file_type = $_FILES['image']['type'];
  $file_ext=strtolower(end(explode('.',$_FILES['image']['name'])));
  
  $extensions= array("jpeg","jpg","png");
  
  if(in_array($file_ext,$extensions)=== false){
   $errors[]="extension not allowed, please choose a JPG, JPEG or PNG file.";
  }
  
  if($file_size &gt; 2097152) {
   $errors[]='File size must be 2 MB';
  }
  
   if(empty($errors)==true) {
   move_uploaded_file($file_tmp,"images/uploads/".$file_name);
  
  $store=mysqli_query($conn,"UPDATE users SET userPic='$userPic' WHERE username='$username'");
  mysqli_query($conn,$store);
   echo "Success";
  }else{
   print_r($errors);
   echo"it failed";
  }
  }
  ?&gt;
  
  &lt;?php
  $getimg = mysqli_query($conn,"SELECT userPic FROM users WHERE username='" . 
  $username . "'");
  $rows=mysqli_fetch_array($getimg);
  $img = $rows['userPic'];
  
  ?&gt;
  
  
  
  &lt;img id="myImg" src="images/uploads/&lt;?php echo $img?&gt;"  alt="&lt;?php echo $img ?&gt;" width="200" height="150"&gt;
  </code></pre>