Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. $con=mysql_connect("localhost","root","alexi") or die('MySQL connect error!');
  4.  
  5. mysql_select_db("users") or die('MySQL select error!');
  6.  
  7. $username=$_POST['username'];
  8. $pass=$_POST['password'];
  9. $confirm_password=$_POST['confirm_passord'];
  10.  
  11. $password=md5($pass);
  12.  
  13. $queryuser=mysql_query("SELECT * FROM accounts WHERE username='$username'");
  14. if (!$queryuser) {
  15.   die('Username not found.');
  16. }
  17.  
  18. $checkuser=mysql_num_rows($queryuser);
  19. if($checkuser != 0) {
  20.   echo "Sorry, ".$username." has already been taken.";
  21. }
  22. else {
  23.  
  24.   $insert_user=mysql_query("INSERT INTO accounts (username, password)
  25.    VALUES ('$username', '$password')");
  26.  
  27.   if($insert_user)
  28.     { echo "Registration Successfull"; }
  29.   else
  30.     { echo "error in registration".mysql_error(); }
  31.  
  32. }
  33.  
  34. mysql_close($con);
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement