成功存储在db中时出现php错误消息

I have code for store some data to data base. Before edit its success store database but problem is when I am refresh duplicate data.

I am edited and worked without any problem but when I press submit and store data to db I get an message error > why ?

this is form code (index.php)

<html>
<head>
<title>Proposals Page</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="columns.css" />
</head>

<body bgcolor="#3AA0BC">
<table border="5">
<form action="enterinfo.php" method="post"><br /><br />
<center> FirstName :<br /><input type="text" name="Name" id="Name" size="25"><br /><br/>
Title :<br />&nbsp;<textarea name="title" id="title" size="50"></textarea></center>
<p><th><input type=submit value="OK" name="submit" id="submit"class="buttStyle"></th</p>
</form>

<form action="view.php" method="post">
<p><th><input type=submit value="عرض المواظيع" class="buttStyle"></th></p></form>
<form action="addcomment.php" method="post">
<p><th><input type=submit value="اضافة تعليق" class="buttStyle"></th></p>
</form>
</body>
</html>

and enter code is (enterinfo.php)

<?php
include ("connect.php");
$Name=isset($_POST['Name']) ?
$_POST['Name'] : '';
$title=isset($_POST['title']) ?
$_POST['title'] : '';
$submit = isset($_POST['submit']) ? 
$_POST['submit'] : '';

if(isset($_POST['submit']))
{
 if($Name && $title)
 {
  $result=mysql_query("INSERT INTO subject(S_Id,Name,title)
                                     VALUES(NULL, '$Name', '$title')");  
  header('Location: enterinfo.php');

 }
}
 if($result)
{
echo "Successful";
echo "<BR>";
}
else
{
echo "error";
}
?>

set a variable in your url after executing your query(i have used re) and check at the top of your page if re exists then echo your message based on re value and exit.
Change your enterinfo.php like below code
Try this:

  if(isset($_REQUEST['re'])){   
    $message = $_REQUEST['re'] == 'success' ? "Sucessfully inserted" : "can not  inserted";   
    echo $message;
    exit();
  }




include ("connect.php");
$Name=isset($_POST['Name']) ?
$_POST['Name'] : '';
$title=isset($_POST['title']) ?
$_POST['title'] : '';
$submit = isset($_POST['submit']) ? 
$_POST['submit'] : '';

 if(isset($_POST['submit']) )
    {
     if($Name && $title)
     {
      $result=mysql_query("INSERT INTO subject(Name,title)
                                         VALUES('$Name', '$title')");  
     if($result){
       header('Location: enterinfo.php?re=success');
      }
      else{
        header('Location: enterinfo.php?re=fails');
       }   
     }
    }
$result=mysql_query("INSERT INTO subject(S_Id,Name,title)
VALUES(NULL, '$Name', '$title')");  

in the above query of yours i think S_Id is a primary key so it cant be NULL.change your above code to and set S_Id to autoincrement

So your insert query should look like:

$result=mysql_query("INSERT INTO subject(Name,title)
                                     VALUES('$Name', '$title')");  

after data update, your are redirecting again same page...

 header('Location: enterinfo.php');

for update a value into a table you should use something like this: UPDATE table SET column1 = expression1, column2 = expression2, ... WHERE conditions;

you cannot "INSERT" a row two times if it contains the same value for a UNIQUE field (like for example the ID)

after data update, your are redirecting again same page...

header('Location: enterinfo.php');

remove header('Location: enterinfo.php'); and then check