Advertisement
Guest User

Untitled

a guest
Dec 6th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.52 KB | None | 0 0
  1. PROFILO PHP
  2.  
  3. <?php
  4.  
  5. include('db_con.php');
  6. if (isset($_SESSION['username']))
  7. {$username = isset($_SESSION['username']) ? $_SESSION["username"] : ""; header('Location: main.php?step=profile.php');}
  8. /*-
  9. else
  10. {
  11. header('Location: main.php?step=sign_up.php');
  12. }
  13. -*/
  14.  
  15. ?>
  16.  
  17.  
  18.  
  19.  
  20. PROFILO HTML
  21. <!-- INIZO PHP -->
  22. <?php
  23. include('navbar.php');
  24. ?>
  25. <div class="clearfix card mb-3 cover" >
  26. <div class="clearfix filter">
  27. <div class="clearfix scrivere" >
  28. <div class="clearfix card-body" >
  29. <!--<div onclick="document.getElementById('file').click(); return false;" id="files" title="Sfondo Profilo">
  30. <img id="image" title="Sfondo Profilo" style="
  31. position: center center;
  32. position: relative;
  33. display: table;
  34. display: table-cell;
  35. vertical-align: middle;
  36. text-align: center;
  37. z-index: 1;
  38. background:#bf4040;
  39. width: 100%;
  40. height:100%;
  41. position: relative;
  42. z-index: 0;
  43. opacity: 0.7;">
  44. </div>
  45. <input id="file" class="clearfix" type="file" name="file" onchange="showImage.call(this)" style="visibility: hidden;">-->
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. <br>
  51. <center class="phpfor"><?php echo $_SESSION['username']; ?></center><br>
  52. <center>
  53. <div id="Img" class="imagy" onclick="document.getElementById('file').click(); return false;" class="clearfix btnr" id="files" title="Immagine Profilo">
  54. <img src="" class="put" id="image">
  55. </div>
  56. </center>
  57. <input id="file" class="clearfix" type="file" name="file" onchange="showImage.call(this)" style="visibility: hidden;">
  58.  
  59.  
  60.  
  61. <div class="footer "></div>
  62. <script>
  63. function showImage(){
  64. if (this.files && this.files[0]) {
  65. var obj= new FileReader();
  66. obj.onload = function(data){
  67. var image= document.getElementById("image")
  68. image.src=data.target.result;
  69. image.style.display="block";
  70.  
  71. }
  72. obj.readAsDataURL(this.files[0]);
  73.  
  74.  
  75. }
  76. }
  77. </script>
  78.  
  79.  
  80.  
  81.  
  82. ACCESSO PHP
  83. <?php
  84.  
  85. include('db_con.php');
  86. if (isset($_POST['login']))
  87. {
  88. $email = isset($_POST['email']) ? $_POST["email"] : "";
  89. $password = isset($_POST['password']) ? $_POST["password"] : "";
  90. if(empty($email) || empty($password))
  91. {
  92. header("Location: main.php?step=log_in.php&campiok=4");
  93. }
  94. elseif (strlen($password) < 6)
  95. {
  96. header("Location: main.php?step=log_in.php&campiok=5");
  97. }
  98. else
  99. {
  100. $q = $db->prepare("
  101. SELECT
  102. *
  103. FROM
  104. users
  105. WHERE
  106. email = :email
  107. ");
  108. $q->execute([
  109. ":email" => $email,
  110. ]);
  111.  
  112. if(($row = $q->fetch(PDO::FETCH_ASSOC))&& password_verify($password, $row["password"]))
  113. {
  114. $_SESSION["username"] = $row["username"];
  115. $_SESSION["email"] = $email;
  116. header("Location: main.php?step=profile.php");
  117. exit();
  118. }
  119. else
  120. {
  121. header("Location: main.php?step=log_in.php&campiok=6");
  122. }
  123. }
  124. }
  125. else
  126. {
  127. header("Location: main.php?step=log_in.php");
  128. }
  129. ?>
  130.  
  131.  
  132. ELIMINAZIONE PHP
  133. <?php
  134.  
  135. include('db_con.php');
  136. if (isset($_SESSION['username']) && isset($_POST['delete']))
  137. {
  138.  
  139. $username = isset($_SESSION['username']) ? $_SESSION["username"] : "";
  140.  
  141. if (empty($_SESSION['username']))
  142. {
  143. header('Location: main.php?step=log_in.php');
  144. }
  145. else{
  146. $q = $db->prepare("
  147. SELECT
  148. *
  149. FROM
  150. users
  151. WHERE
  152. username = :username
  153. ");
  154. $q->execute([
  155. ":username" => $username,
  156. ]);
  157.  
  158.  
  159. if(($row = $q->fetch(PDO::FETCH_ASSOC))) {
  160.  
  161. $q = $db->prepare("
  162. DELETE FROM users WHERE username=:username
  163. ");
  164. $q->execute([
  165.  
  166. ":username" => $username
  167.  
  168. ]); }
  169. }
  170. }
  171.  
  172. else{ header('Location: main.php?step=delete.php'); }
  173.  
  174. /*-
  175. include('db_con.php');
  176. $q = $db->prepare("
  177. DELETE FROM users WHERE username=:username
  178. ");
  179. if ($q->execute([":username" => $username]))
  180. {
  181. session_destroy() && header('Location: main.php?step=sign_up.php');
  182. }
  183. else
  184. {
  185. echo "Errore nella query: " . $q->errorInfo();
  186. }
  187. -*/
  188.  
  189. ?>
  190.  
  191. ELIMINAZIONE HTML
  192. <?php include('navbar.php');
  193. ?>
  194. <div class="clearfix card mb-3 cover">
  195. <div class="clearfix filter">
  196. <div class="clearfix scrivere">
  197. <div class="clearfix card-body copy">
  198. <div class="clearfix card-title scrivere logo font-weight-bold"><br></div>
  199. </div>
  200. </div>
  201. </div>
  202. </div>
  203. <center>
  204.  
  205. <!--PROBLEMA IN ACTION-->
  206.  
  207. <form class="clearfix single form-control" action="" method="POST">
  208. <center class="phpfor"><?php echo $_SESSION['username']; ?></center><br>
  209. <p id="emailHelp" class="clearfix form-text text error text-center">Vuoi procedere?</p>
  210. <div class="clearfix form-group">
  211. <div class="clearfix col-sm-10">
  212. <a href="javascript:history.back();" class="clearfix btn clearfix">Annulla</a>
  213. </div>
  214. </div>
  215. <div class="clearfix form-group">
  216. <div class="clearfix col-sm-10">
  217. <button type="submit" class="clearfix btn clearfix" name="delete">Elimina</button>
  218. </div>
  219. </div>
  220. </form>
  221. </center>
  222. <div class="footer "></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement