Advertisement
Guest User

Untitled

a guest
Feb 28th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. <?php
  2. include 'header.php';
  3.  
  4. session_start();
  5.  
  6. //kick none users off the page
  7. if(isset($_SESSION["UserID"])) {
  8.  
  9. }
  10. else {
  11. header('Location:login.php');
  12. }
  13.  
  14. //Diaplay the user info
  15. $user = $_SESSION[UserID];
  16.  
  17. $results = $con->query("select * from users where UserID='$user'");
  18.  
  19. $row = $results->fetch_array(MYSQLI_BOTH);
  20.  
  21. session_start();
  22.  
  23. $_SESSION["FirstName"] = $row['FirstName'];
  24. $_SESSION["LastName"] = $row['LastName'];
  25. $_SESSION["Email"] = $row['Email'];
  26. $_SESSION["Password"] = $row['Password'];
  27.  
  28. //update user info
  29. if(isset($_POST['update'])){
  30.  
  31. $UpdateFN = $_POST['First_Name'];
  32. $UpdateLN = $_POST['Last_Name'];
  33. $UpdateEM = $_POST['Email'];
  34. $UpdatePW = $_POST['Password'];
  35.  
  36. $StorePassword = password_hash($UpdatePW, PASSWORD_BCRYPT, array('cost' => 10));
  37.  
  38. $sql = $con->query("UPDATE users SET FirstName = '{$UpdateFN}', LastName = '{$UpdateLN}', Email = '{$UpdateEM}', Password = '{$StorePassword}' where UserID=$user");
  39.  
  40. header('Location:account.php');
  41. }
  42.  
  43. ?>
  44.  
  45. <!DOCTYPE html>
  46. <html lang="en">
  47. <head>
  48. <meta charset="utf-8" />
  49. <title></title>
  50. </head>
  51. <body>
  52. <p>Your account</p>
  53. <?php echo $_SESSION[UserID]; ?><br />
  54. <a href="logout.php">Logout</a>
  55.  
  56.  
  57.  
  58. <form action="" method="post" name="AccountForm" id="AccountForm" >
  59. <input type="text" name="First_Name" placeholder="First Name" id="First_Name" required="required" value="<?php echo $_SESSION["FirstName"]?>"><br>
  60. <input type="text" name="Last_Name" placeholder="Last Name" id="Last_Name" required="required" value="<?php echo $_SESSION["LastName"]?>"><br>
  61. <input type="text" name="Email" placeholder="Email" id="Email" required="required" value="<?php echo $_SESSION["Email"]?>"><br>
  62. <input type="password" name="Password" placeholder="Password" id="Password" required="required" value="<?php echo $_SESSION["Password"]?>"><br><br>
  63. <input name="update" type="submit" value="Update">
  64. </form>
  65.  
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement