Advertisement
Guest User

Untitled

a guest
Jul 6th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $user = "globalty_trans";
  4. $password = "transport2019";
  5. $name = "globalty_tranport";
  6. try{
  7. $con = new mysqli($host, $user, $password,$name);
  8. if($con->connect_error) {
  9. die("error " . $con->connect_error);
  10. }
  11. }catch(Exception $e){}
  12.  
  13. if(isset($_POST['insert'])){
  14. $fullName=$_POST['fn'];
  15. $email=$_POST['em'];
  16. $password=$_POST['pas'];
  17. $pasHash = password_hash($password, PASSWORD_BCRYPT,array(cost <= 12));
  18.  
  19. $check = mysqli_prepare($con, "SELECT * FROM users WHERE username = ?");
  20. if ($check) {
  21. $check->bind_param("s", $email);
  22. $check->execute();
  23. $result = $check->get_result();
  24. $num_of_rows = $result->num_rows;
  25. if($num_of_rows == 0){
  26. try{
  27. $insert = mysqli_prepare($con, "INSERT INTO users (fullname,username,password) VALUES (?,?,?)");
  28. $insert->bind_param("sss", $fullName,$email, $pasHash);
  29. $insert->execute();
  30. echo "0";
  31. }catch(Exception $e){
  32. echo "1";
  33. }
  34. }
  35. else{
  36. echo "2";
  37. }
  38. }
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement