Advertisement
Guest User

Untitled

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