Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2019
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. <?php
  2. if(isset($_POST["submit"])){
  3. if(!empty($_POST['user']) && !empty($_POST['pass'])) {
  4. $user=$_POST['user'];
  5. $pass=$_POST['pass'];
  6. $con=mysqli_connect('localhost','root','','mydb') or die(mysql_error());
  7.  
  8. $query=mysqli_query($con,"SELECT * FROM user_registration WHERE username='".$user."'");
  9. $numrows=mysqli_num_rows($query);
  10. if($numrows==0)
  11. {
  12. $sql="INSERT INTO user_registration(username,password) VALUES('$user','$pass')";
  13.  
  14. $result=mysqli_query($con,$sql);
  15. if($result){
  16. echo "Account Successfully Created";
  17. header("Location: index.php");
  18. } else {
  19. echo "Failure!";
  20. }
  21.  
  22. } else {
  23. echo "That username already exists! Please try again with another.";
  24. }
  25.  
  26. } else {
  27. echo "All fields are required!";
  28. }
  29. }
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement