This is the code I have written:
index.html
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form action="db.php" method="post">
YES:<input type="radio" name="YES" value="YES">
NO:<input type="radio" name="NO" value="NO" >
<input type="submit" name="submit value="submit">
</form>
</body>
<html>
db.php
<?php
$con = mysqli_connect('localhost','my user id','my password');
if(!con)
{ echo 'not connected to server';}else { echo 'something else is wrong' ;}
if(!mysqli_select_db($con,'my user id')
{ echo 'Database error selection';}
$YES = $_POST['YES'];
$NO = $_POST['NO'];
$sql = INSERT INTO users (YES,NO) VALUES ('$YES','$NO');
if(!mysqli_query($con,$sql))
{ echo 'Answer not submitted please try again!!!!!!!!';}
else{
echo 'Your answer successfully submitted \n Thanks for participating';}
header(" refresh:2; url=index.html");
?>
There is something wrong in it. Can anyone please tell what is wrong?
Note: If 2 users submit YES then in database YES would get int value as 2 If 1 users submit NO then in database NO would get int value as 1.