This is how the code looks for the insert.php file. Every time I run this code I get the same error that my variables are not defined. Below also you have my index page
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = 'admin';
$dbname = 'test_emilian';
$con = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
// check the connection
if ($con->connect_errno){
die("Failed to connect to MySQL: (" . $con->connect_errno . ") " . $con->connect_error);
}
$id = mysqli_real_escape_string($con,$_POST['id']);
$first = mysqli_real_escape_string($con,$_POST['first']);
$last = mysqli_real_escape_string($con,$_POST['last']);
$email = mysqli_real_escape_string($con,$_POST['email']);
$mobile = mysqli_real_escape_string($con,$_POST['mobile']);
$date = mysqli_real_escape_string($con,$_POST['date']);
$gender = mysqli_real_escape_string($con,$_POST['gender']);
$cnp = mysqli_real_escape_string($con,$_POST['cnp']);
//made the INSERT duction
$AddQuery = "INSERT INTO useri (first,last,email,mobile,date,gender,cnp) values ('".$id."','".$first."','".$last."','".$email."','".$mobile."','".$date."','".$gender."','".$cnp."')";
if (!mysqli_query($con,$AddQuery))
{echo 'Not Inserted';
}else{
echo 'Inserted Successfully';
}
This is where I have defined the variables
echo "<tr><form action=insert.php method = post>";
echo "<tr>";
echo "<td><input type=text name =first></input></td>";
echo "<td><input type=text name =last></input></td>";
echo "<td><input type=text name =email></input></td>";
echo "<td><input type=text name =mobile></input></td>";
echo "<td><input type=text name =date></input></td>";
echo "<td><input type=text name =gender></input></td>";
echo "<td><input type=text name =cnp></input></td>";
echo "<td><input type=submit name =add value = add>" ."</td</tr>";
echo "</form>";
echo "</table>";
?>
at the end is not inserting anything.