Advertisement
Guest User

Untitled

a guest
Oct 14th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. <?php
  2.  
  3. $user = "root";
  4. $pass = "";
  5. $loggedin;
  6. $conn = new PDO('mysql:host=localhost;dbname=login', $user, $pass);
  7.  
  8. if (!$conn) {
  9. die("Connection to the database failed");
  10. }
  11.  
  12. <?php
  13.  
  14. include '../dbh.php';
  15.  
  16. $first = $_POST['first'];
  17. $last = $_POST['last'];
  18. $uid = $_POST['uid'];
  19. $pwd = $_POST['pwd'];
  20.  
  21. if (empty($first)) {
  22. header("Location: ../signup.php?error=empty");
  23. exit();
  24. } if (empty($last)) {
  25. header("Location: ../signup.php?error=empty");
  26. exit();
  27. } if (empty($uid)) {
  28. header("Location: ../signup.php?error=empty");
  29. exit();
  30. } if (empty($pwd)) {
  31. header("Location: ../signup.php?error=empty");
  32. exit();
  33. } else {
  34.  
  35. $sql = "SELECT uid FROM users WHERE uid='$uid'";
  36. $result = mysqli_query($conn, $sql);
  37. $uidcheck = mysqli_num_rows($result);
  38.  
  39. if ($uidcheck > 0) {
  40. header("Location: ../signup.php?error=username");
  41. exit();
  42. } else {
  43. $sql = "INSERT INTO users (first, last, uid, pwd)
  44. VALUES ('$first', '$last', '$uid', '$pwd')";
  45.  
  46. $result = mysqli_query($conn, $sql);
  47.  
  48. header("Location: ../index.php");
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement