Guest User

Untitled

a guest
Feb 25th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. <?php
  2. $conn = mysqli_connect ("localhost","root","","facility");
  3. $query = "SELECT * FROM user WHERE IDNo = 11";
  4.  
  5. $result = mysqli_query($conn, $query);
  6.  
  7. while($row = mysqli_fetch_array($result)) {
  8.  
  9. echo '<tr><td>
  10. <img src = "data:image/jpeg;base64,'.base64_encode($row ['Image']). '"/>
  11. </td> </tr> ';}
  12.  
  13. ?>
  14.  
  15. $Image = file_get_contents($_FILES['image']['name']);
  16. $ImageLoc = file_get_contents($_FILES['image']
  17. ['name']);
  18. $imagesize = getimagesize($_FILES['image']
  19. ['tmp_name']);
  20. $target = "upload/".basename($Image);
  21.  
  22. if (move_uploaded_file($_FILES['image']['tmp_name'], $target)){
  23.  
  24. }else {
  25. array_push($errors, "Failed to upload image");
  26. }
  27.  
  28.  
  29. if (count($errorMessage) <= 0) {
  30.  
  31. // save to database
  32. $data = [
  33. 'IDNo' => $IDNo,
  34. 'FullName' => $FullName,
  35. 'username' => $Username,
  36. 'Type' => $Type,
  37. 'Dept' => $Dept,
  38. 'Password' => $Password,
  39. 'Email' => $Email,
  40. 'Role' => $Role,
  41. 'Image' => $Image,
  42. 'ImageLoc' => $ImageLoc,
  43. ];
  44. $id = $mysql->insert('user', $data);
  45.  
  46. $_SESSION['message'] = "Successfully added $FullName";
  47. header('location: users.php');
  48.  
  49.  
  50.  
  51. if(isset($_POST['Type'])){
  52. $Type = e($_POST['Type']);
  53. $query = "INSERT INTO user (IDNo , FullName , username , Type , Dept , Password , Email , Role , Image , ImageLoc)
  54. VALUES('$IDNo', '$FullName', '$username', '$Type', '$Dept', '$Password', '$Email','$Role' , '$Image' , '$ImageLoc')";
  55.  
  56. mysqli_query($conn, $query);
  57. $_SESSION['success'] = "New user successfully created!!";
  58. header('location: users.php');
  59. } else{
  60. $query = "INSERT INTO user (IDNo , FullName , username , Type , Dept , Password , Email , Role , Image , ImageLoc)
  61. VALUES('$IDNo', '$FullName', '$Username', '$Type', '$Dept', '$Password', '$Email','$Role' , '$Image' , '$ImageLoc')";
  62. mysqli_query($conn, $query);
  63.  
  64.  
  65. }
  66. }
Add Comment
Please, Sign In to add comment