Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST["submit"])){
- if(!empty($_POST['user']) && !empty($_POST['pass'])) {
- $user=$_POST['user'];
- $pass=$_POST['pass'];
- $con=mysqli_connect('localhost','root','','mydb') or die(mysql_error());
- $query=mysqli_query($con,"SELECT * FROM user_registration WHERE username='".$user."'");
- $numrows=mysqli_num_rows($query);
- if($numrows==0)
- {
- $sql="INSERT INTO user_registration(username,password) VALUES('$user','$pass')";
- $result=mysqli_query($con,$sql);
- if($result){
- echo "Account Successfully Created";
- header("Location: index.php");
- } else {
- echo "Failure!";
- }
- } else {
- echo "That username already exists! Please try again with another.";
- }
- } else {
- echo "All fields are required!";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement