this my code both form.html and insert.php
<!DOCTYPE html>
<html>
<head>
<title>form</title>
</head>
<body>
<form action="insert.php" method="POST">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="username" placeholder="name" required></td>
</tr>
<tr>
<td>password:</td>
<td><input type="password" name="password" placeholder="password" required></td>
</tr>
<tr>
<td>gender</td>
<td>
<input type="radio" name="gender" value="m" required> male
<input type="radio" name="gender" value="f" required>female
</td>
</tr>
<tr>
<td>email:</td>
<td><input type="mail" name="email" placeholder="email" required></td>
</tr>
<tr>
<td>phone no:</td>
<td>
<select name="phonecode" required>
<option selected hidden value="">
select code
</option>
<option>
<option>
080
</option>
</select>
<input type="phone" name="phone" required>
</td>
</tr>
<tr>
<td>
<input type="submit" value="submit" name="">
</td>
</tr>
</table>
</form>
</body>
</html>
insert.php
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$phonecode = $_POST['phonecode'];
$phone = $_POST['phone'];
if (!empty($username) || !empty($password) || !empty($gender) || !empty($email) || !empty($phonecode) || !empty($phone)){
$host = "localhost";
$dbusername = "root";
$dbPassword = "";
$dbname = "web";
if(mysqli_connect_error()){
die('Connect Error('. mysqli_connect_error().')'. mysqli_connect_error());
}
else{
$SELECT = "SELECT email From register where email= ? Limit 1";
$INSERT = "INSERT Into register(username, Passwd, gender, email, phonecode,phone) value(?,?,?,?,?,?)";
if($rnum==0){
$stmt->close();
$stmt->$conn->prepare($INSERT);
$stmt->bind_param("ssssii",$username,$password,$gender,$email,$phonecode,$phone);
$stmt->execute();
echo "new record inserted successfully";
}else{
echo "someone already register using this email";
}
$stmt->close();
$conn->close();
}
}
else{
echo"all fields required";
die();
}
?>
even all permissions are set
<!DOCTYPE html>
<html>
<head>
<title>form</title>
</head>
<body>
<form action="insert.php" method="POST">
<table>
<tr>
<td>Name:</td>
<td><input type="text" name="username" placeholder="name" required></td>
</tr>
<tr>
<td>password:</td>
<td><input type="password" name="password" placeholder="password" required></td>
</tr>
<tr>
<td>gender</td>
<td>
<input type="radio" name="gender" value="m" required> male
<input type="radio" name="gender" value="f" required>female
</td>
</tr>
<tr>
<td>email:</td>
<td><input type="mail" name="email" placeholder="email" required></td>
</tr>
<tr>
<td>phone no:</td>
<td>
<select name="phonecode" required>
<option selected hidden value="">
select code
</option>
<option>
91
<option>
080
</option>
</select>
<input type="phone" name="phone" required>
</td>
</tr>
<tr>
<td>
<input type="submit" value="submit" name="">
</td>
</tr>
</table>
</form>
</body>
</html>
insert.php
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$phonecode = $_POST['phonecode'];
$phone = $_POST['phone'];
if (!empty($username) || !empty($password) || !empty($gender) || !empty($email) || !empty($phonecode) || !empty($phone)){
$host = "localhost";
$dbusername = "root";
$dbPassword = "";
$dbname = "web";
Code Block $conn = new mysqli($host, $dbusername, $dbPassword, $dbname);
if(mysqli_connect_error()){
die('Connect Error('. mysqli_connect_error().')'. mysqli_connect_error());
}
else{
$SELECT = "SELECT email From register where email= ? Limit 1";
$INSERT = "INSERT Into register(username, Passwd, gender, email, phonecode,phone) value(?,?,?,?,?,?)";
Code Block $stmt = $conn->prepare($SELECT); $stmt->bind_param("s",$email); $stmt->execute(); $stmt->bind_result($email); $stmt->store_result(); $rnum = $stmt->num_rows;
if($rnum==0){
$stmt->close();
$stmt->$conn->prepare($INSERT);
$stmt->bind_param("ssssii",$username,$password,$gender,$email,$phonecode,$phone);
$stmt->execute();
echo "new record inserted successfully";
}else{
echo "someone already register using this email";
}
$stmt->close();
$conn->close();
}
}
else{
echo"all fields required";
die();
}
?>
even all permissions are set