Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.05 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. require_once 'DB_info.php';
  6.  
  7. require_once 'UTILS.php';
  8.  
  9.  
  10.  
  11. $servername = "localhost";
  12. $Username = "username";
  13. $Password = "password";
  14.  
  15.  
  16.  
  17. $conn = new mysqli($servername, $username, $password, $dbname);
  18.  
  19.  
  20.  
  21. if ($conn->connect_error) {
  22.  
  23.     die("Connection failed: " . $conn->connect_error);
  24.  
  25. }
  26.  
  27.  
  28. $sql = "SELECT username FROM $users WHERE username='$username'";
  29.  
  30. $result = $conn->query($sql);
  31.  
  32.  
  33.  
  34. checkErrorReturn
  35.  
  36.     ($result->num_rows > 0,
  37.  
  38.      "There is already an account associated with this username",
  39.  
  40.      "Back to registration page",
  41.  
  42.      "register.php");
  43.  
  44.  
  45.  
  46.  
  47. $sql = "INSERT INTO $users
  48.  
  49. VALUES ('$username', '$firstName', '$lastName', '$email', '$password')";
  50.  
  51.  
  52. checkErrorReturn
  53.  
  54.     (! $conn->query($sql),
  55.  
  56.      $sql . "<br>" . $conn->error,
  57.  
  58.      "Back to registration page",
  59.  
  60.      "register.php");
  61.  
  62.  
  63.  
  64. $conn->close();
  65.  
  66. echo "<h1> Welcome $username! You were successfully
  67.  
  68. registered! </h1>";
  69.  
  70.  
  71.  
  72. echo '<h1> <a href="login.html"> Go to the login page </a> </h1>';
  73.  
  74.  
  75.  
  76.  
  77.  
  78. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement