Advertisement
Guest User

Untitled

a guest
Oct 9th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. if( isset($_SESSION['user'])!="" ){
  6.  
  7. header("Location: profile.php");
  8.  
  9. }
  10.  
  11. include_once 'connect.php';
  12.  
  13.  
  14.  
  15. if ( isset($_POST['sca']) ) {
  16.  
  17. $username = trim($_POST['username']);
  18.  
  19. $fname = trim($_POST['fname']);
  20.  
  21. $lname = trim($_POST['lname']);
  22.  
  23. $pass = trim($_POST['password']);
  24.  
  25. $password = hash('sha256', $pass);
  26.  
  27.  
  28.  
  29.  
  30.  
  31. $query = "insert into people(username,fname,lname,password)
  32.  
  33. values(?, ?, ?, ?)";
  34.  
  35. $stmt = $pdo->prepare($query);
  36.  
  37. $stmt->execute([$username,$fname,$lname,$password]);
  38.  
  39. $rowsAdded = $stmt->rowCount();
  40.  
  41.  
  42.  
  43. if ($rowsAdded == 1) {
  44.  
  45. $message = "Success! Go Log in now Buddy!";
  46.  
  47. unset($fname);
  48.  
  49. unset($lname);
  50.  
  51. unset($pass);
  52.  
  53. header("Location: login.php");
  54.  
  55. }
  56.  
  57. else
  58.  
  59. {
  60.  
  61. $message = "Failed! Try again Buddy!";
  62.  
  63. }
  64.  
  65. }
  66.  
  67. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement