I have created an HTML form after submitting it below php code executes. The problem is that every time, page is refreshed or rerun, the if condition statement appears without clicking the Save button and null values are being stored in database table. Please help me how can I resolve it?
<?php
include 'connection.php';
if ($_POST['submit'] == 'Save')
{
$student_no=$_POST['student_no'];
$student_name=$_POST['student_name'];
$sqlQuery= "INSERT INTO student_info (student_no, student_name) VALUES('$student_no','$student_name');";
if(mysql_query($sqlQuery, $con))
{
echo "Data Successfully Saved";
}
else
die("Connection Error:". mysql_error());
}
mysql_close($con);
?>