Advertisement
Guest User

Untitled

a guest
Mar 29th, 2015
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. <?php
  2. include_once 'includes/db_connect.php';
  3. include_once 'includes/functions.php';
  4.  
  5. sec_session_start();
  6. ?>
  7.  
  8. <?php
  9. if(isset($_POST['submit'])){
  10. move_uploaded_file($_FILES['file']['tmp_name'],"pictures/".$_FILES['file']['name']);
  11. $con = mysqli_connect("localhost","root","","secure_login");
  12. $q = mysqli_query($con,"UPDATE users SET image = '".$_FILES['file']['name']."' WHERE username = '".$_SESSION['username']."'");
  13. }
  14. ?>
  15. <!DOCTYPE html>
  16. <html>
  17. <head>
  18. <meta charset="UTF-8">
  19. <title>Secure Login: Protected Page</title>
  20. <link rel="stylesheet" href="css/me.css" />
  21. <link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,400,300,700' rel='stylesheet' type='text/css'>
  22. </head>
  23. <body>
  24. <div id="wrap">
  25. <?php if (login_check($mysqli) == true) : ?>
  26. <p id="meusername"><?php echo htmlentities($_SESSION['username']); ?>!</p>
  27. <p>
  28. This is an example protected page. To access this page, users
  29. must be logged in. At some stage, we'll also check the role of
  30. the user, so pages will be able to determine the type of user
  31. authorised to access the page.
  32.  
  33. <form action="" method="post" enctype="multipart/form-data">
  34. <input type="file" name="file">
  35. <input type="submit" name="submit">
  36. </form>
  37. <?php
  38. $con = mysqli_connect("localhost","root","","secure_login");
  39. $q = mysqli_query($con,"SELECT * FROM members");
  40. while($row = mysqli_fetch_assoc($q)){
  41. echo $row['username'];
  42. if ($row['image'] == ""){
  43. echo "<img width='100' height='100' src='pictures/default.jpg' alt='Default Profile Pic'>";
  44. } else {
  45. echo "<img width='100' height='100' src='pictures/".$row['image']."' alt='Profile Pic'>";
  46. }
  47. echo "<br>";
  48. }
  49. ?>
  50.  
  51. </p>
  52. <p>Return to <a href="includes/logout">login page</a></p>
  53. <?php else : ?>
  54. <p>
  55. <span class="error">You are not authorized to access this page.</span> Please <a href="index">login</a>.
  56. </p>
  57. <?php endif; ?>
  58. </div>
  59. </body>
  60. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement