Guest User

Untitled

a guest
Jan 19th, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. /* This code will make a connection with database */
  4. $con=mysql_connect("localhost","root","root123");
  5.  
  6. /* Now, we select the database */
  7. mysql_select_db("cus_1");
  8.  
  9. /* Now we will store the values submitted by form in variable */
  10. $username=$_GET['username'];
  11. $pass=$_GET['email'];
  12. $phone_number=$_GET['phone_number'];
  13.  
  14. /* Now we will check if username is already in use or not */
  15. $queryuser=mysql_query("SELECT * FROM login WHERE username='$username' ");
  16. $checkuser=mysql_num_rows($queryuser);
  17. if($checkuser != 0)
  18. { echo "Sorry, ".$username." is already been taken."; }
  19. else {
  20.  
  21. /* now we will check if password and confirm password matched */
  22. if($pass == $confirm_password)
  23. { echo "Password and confirm password fields were not matched"; }
  24.  
  25. else {
  26.  
  27. /* Now we will write a query to insert user details into database */
  28. $insert_user=mysql_query("INSERT INTO cus_book (cus_name, cus_email, cus_key) VALUES ('$username', '$pass', '$phone_number')");
  29.  
  30. if($insert_user)
  31. { echo "VALID"; }
  32. else
  33. { echo "error in registration".mysql_error(); }
  34.  
  35. /* closing the if else statements */
  36. }}
  37.  
  38. mysql_close($con);
  39.  
  40. ?>
Add Comment
Please, Sign In to add comment