Advertisement
Guest User

php mysql code

a guest
Dec 19th, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. if(!empty($_POST['username']) &&!empty($_POST['email']) &&!empty($_POST['password'])) {
  5. $username=$_POST['username'];
  6. $email=$_POST['email'];
  7. $password=$_POST['password'];
  8.  
  9.  
  10. $con=mysql_connect('localhost','root','') or die(mysql_error());
  11. mysql_select_db('registration', $con) or die("cannot select DB");
  12.  
  13. $query=mysql_query("SELECT * FROM reg1 WHERE username='".$username."'");
  14. $numrows=mysql_num_rows($query);
  15. if($numrows==0)
  16. {
  17. $sql="INSERT INTO reg1 (username,email,password) VALUES('$username','$email','$password')";
  18.  
  19. $result=mysql_query($sql);
  20.  
  21.  
  22. if($result){
  23. echo " Your Account Has Been Successfully Created!.";
  24. } else {
  25. echo "Failure!";
  26. }
  27.  
  28. } else {
  29. echo "The username you have entered already exists!.";
  30. }
  31.  
  32. } else {
  33. echo "All fields are required!";
  34. }
  35.  
  36.  
  37. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement