Advertisement
Guest User

Untitled

a guest
Mar 14th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. // Check input errors before inserting in database
  2. if(empty($username_err) && empty($password_err) && empty($Email_err) && empty($Phone_err) && empty($Address_err) && empty($confirm_password_err)){
  3.  
  4. // Prepare an insert statement
  5. $sql = "INSERT INTO Staff (username,password,Email,Phone,Address) VALUES (?, ?,?,?,?)";
  6.  
  7. if($stmt = mysqli_prepare($link, $sql)){
  8. // Bind variables to the prepared statement as parameters
  9. mysqli_stmt_bind_param($stmt, "sssss", $param_username, $param_password,$param_Email,$param_Phone,$param_Address);
  10.  
  11. // Set parameters
  12. $param_username = $username;
  13. $param_password = password_hash($password, PASSWORD_DEFAULT); // Creates a password hash
  14. $param_username = $Email;
  15. $param_username = $Phone;
  16. $param_username = $Address;
  17.  
  18. // Attempt to execute the prepared statement
  19. if(mysqli_stmt_execute($stmt)){
  20. // Redirect to login page
  21. header("location: login.php");
  22. } else{
  23. echo "Something went wrong. Please try again later.";
  24. }
  25. }
  26.  
  27. // Close statement
  28. mysqli_stmt_close($stmt);
  29. }
  30.  
  31. // Close connection
  32. mysqli_close($link); } ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement