0
<?php  
include("connect.php");  
if(isset($_POST['submit']))  
{  
    $qonax=@$_POST['qonax'];  
    $subject=@$_POST['subject'];  
    $insert="INSERT INTO subject(ID,Qonax,Subject)VALUES('','$qonax','$subject')";  
    mysqli_query($link,$insert) or die(mysql_error($link));  
}  
header('location:insert_subject.php');  
?>  

appear this:
enter image description here

This error appear when write (if(isset($_POST['submit']){ } when removed this line code a problem fixed.

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
Talib
  • 25
  • 3
  • 9
  • 1
    show the form too – Exprator Jul 06 '17 at 08:20
  • 2
    Your script is at risk of [SQL Injection Attack](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php) Have a look at what happened to [Little Bobby Tables](http://bobby-tables.com/) Even [if you are escaping inputs, its not safe!](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) Use [prepared parameterized statements](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php) – RiggsFolly Jul 06 '17 at 08:24
  • 3
    i think you did header() redirection to the same file. Am i right.? – Sahathulla Jul 06 '17 at 08:25
  • almost certainly you're redirecting back to the same script again, creating an infinite loop – ADyson Jul 06 '17 at 08:50

1 Answers1

0

move the redirection inside the if block and unsetting the $_POST['submit'] variable

<?php  
include("connect.php");  
if(isset($_POST['submit']))  
{  
    $qonax=@$_POST['qonax'];  
    $subject=@$_POST['subject'];  
    $insert="INSERT INTO subject(ID,Qonax,Subject)VALUES('','$qonax','$subject')";  
    mysqli_query($link,$insert) or die(mysql_error($link));
    unset($_POST['submit'])  
    header('location:insert_subject.php');
}  
?> 
taha
  • 997
  • 9
  • 17