Guest User

Untitled

a guest
Jun 22nd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. <?php
  2.  
  3. // Include the needed file(s)
  4. require_once("config.php");
  5.  
  6. if($isLogged == false) {
  7.  
  8. // Not logged in, redirect them I say!
  9. core::redir("login.php", "You must be logged in to view this page.", "4", "error");
  10.  
  11. }
  12.  
  13. else {
  14.  
  15. $userID = $userInfo['userid'];
  16.  
  17. // Check to see if the form has been posted, if not display in php
  18. if(!$_POST['settings']) {
  19.  
  20. ?>
  21. <p>Any fields that are cleared will revert to their previous data. Leave password blank to avoid changing.</p>
  22. <form method="post">
  23.  
  24. <p>Username<br/><input type="text" name="username" value="<?php echo $userInfo['username'] ?>"/></p>
  25. <p>Password<br/><input type="password" name="password"/></p>
  26. <p>First Name<br/><input type="text" name="fname" value="<?php echo $userInfo['fname'] ?>"/></p>
  27. <p>Last Name<br/><input type="text" name="lname" value="<?php echo $userInfo['lname'] ?>"/></p>
  28. <p>Website<br/><input type="text" name="website" value="<?php echo $userInfo['website'] ?>"/></p>
  29. <p>Email<br/><input type="text" name="email" value="<?php echo $userInfo['email'] ?>"/></p>
  30. <p>Bio<br/><textarea name="bio"><?php echo $userInfo['bio'] ?></textarea></p>
  31. <p><input type="submit" name="settings" value="Update"/></p>
  32.  
  33. </form>
  34.  
  35. <?
  36.  
  37. }
  38.  
  39. else {
  40.  
  41. // Only insert stuff that's changed, no point commenting PHP cause if you don't know it well enough to read code it'll be difficult to comprehend
  42. foreach($_POST as $key => $value){
  43.  
  44. if($key != "settings" && $value != ""){
  45.  
  46. $key = core::cleanString($value);
  47.  
  48. if($key == "password") { $key = md5($value); }
  49.  
  50. db::update("users", "$key = '$value'", "userid = '$userID'");
  51.  
  52. }
  53.  
  54. }
  55.  
  56. echo "Success updating your settings.";
  57.  
  58. }
  59.  
  60. }
  61.  
  62. ?>
Add Comment
Please, Sign In to add comment