I have created a form in php and html and I am getting following errors.Tried to find solution but in vain. I am working on localhost
Warning: Undefined variable $usersname in C:\xampp\htdocs\signup\signup.php on line 14
Warning: Undefined variable $fname in C:\xampp\htdocs\signup\signup.php on line 14
Warning: Undefined variable $lname in C:\xampp\htdocs\signup\signup.php on line 14
Warning: Undefined variable $email in C:\xampp\htdocs\signup\signup.php on line 14
Warning: Undefined variable $states in C:\xampp\htdocs\signup\signup.php on line 14
Warning: Undefined variable $gender in C:\xampp\htdocs\signup\signup.php on line 14
<?php
include "config.php";
if(isset($_POST['crateaccount']))
{
$usersname = $_POST['usersname'];
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['useremail'];
$states = $_POST['states'];
$gender = $_POST['gender'];
}
$insert = "INSERT INTO registrationform (username,firstname,lastname,email,state,gender) VALUES('$usersname','$fname','$lname','$email','$states','$gender') ";
$query = mysqli_query($con, $insert);
if(!$query)
{
echo "Failed";
}
?>