But i am facing this error
Fatal error: Uncaught TypeError: mysqli_query(): Argument #1 ($mysql) must be of type mysqli, bool given in F:\Xampp\htdocs\User-Registration-System\index.php:20 Stack trace: #0 F:\Xampp\htdocs\User-Registration-System\index.php(20): mysqli_query(false, 'SELECT * FROM `...') #1 {main} thrown in F:\Xampp\htdocs\User-Registration-System\index.php on line 20
<?php include 'connection.php';
if (isset($_REQUEST['register'])) {
$username = $_POST['username'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$password = md5($_POST['password']);
$cpassword = md5($_POST['cpassword']);
if (
empty($_POST['username']) ||
empty($_POST['email']) ||
empty($_POST['mobile']) ||
empty($_POST['password']) ||
empty($_POST['cpassword'])
) {
echo 'Please fill all required fields!';
} else {
$usernameQuery = "SELECT * FROM `register` WHERE `username`='$username'";
$uq = mysqli_query($conn, $usernameQuery);
$emailQuery = "SELECT * FROM `register` WHERE `email`='$email'";
$eq = mysqli_query($conn, $emailQuery);
$mobileQuery = "SELECT * FROM `register` WHERE `mobile`=$mobile";
$pq = mysqli_query($conn, $mobileQuery);
if (mysqli_num_rows($uq > 0)) {
echo "username already exist";
} elseif (mysqli_num_rows($eq > 0)) {
echo "username already exist";
} elseif (mysqli_num_rows($pq > 0)) {
echo "someone already register with this phone number";
} elseif ($password === $cpassword) {
$iquery = "INSERT INTO `register`(`username`,`eamil`,`mobile`,`password`) VALUES('$username','$email','$mobile','$password')";
mysqli_query($conn, $iquery);
} else (header('location:index.php'));
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
</head>
<body>
<div class="container">
<div class="h1">Register Here</div>
<form action="" method="post">
<div class="form-group">
<label for="exampleInputEmail1">Username</label>
<input type="text" class="form-control" name="username" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Email</label>
<input type="email" class="form-control" name="email" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Mobile</label>
<input type="text" class="form-control" name="mobile" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Password</label>
<input type="password" class="form-control" name="password" id="exampleInputPassword1" placeholder="Password">
</div>
<div class="form-group">
<label for="exampleInputPassword1">Confirm Password</label>
<input type="password" class="form-control" name="cpassword" id="exampleInputPassword1" placeholder="Password">
</div>
<br>
<button type="submit" name="register" class="btn btn-primary">Submit</button>
</form>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
</body>
</html>