How to stop sending input form data to SQL database on browser refresh?
<p>On every browser refresh old data that have already been sent to database are sending again.
I want to insert data in database if the input name 'title' have some value.</p>

<p>This is my html form:</p>

<pre><code>&lt;form method="post" enctype="multipart/form-data"&gt;
&lt;table&gt;
&lt;tr&gt;
&lt;td&gt;&lt;p&gt;Title: &lt;input type="text" name="title"&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;p&gt;Comment: &lt;input type="text" name="comment" class="inputtext"&gt;&lt;/p&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;  
&lt;input type="hidden" name="MAX_FILE_SIZE"value="16000000"&gt;
&lt;input name="userfile" type="file" id="userfile"&gt; 
&lt;/td&gt;
&lt;td width="80"&gt;&lt;input name="upload"type="submit" class="box" id="upload" value=" Upload "&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/form&gt;
</code></pre>

<p>My php code:</p>

<pre><code>&lt;?php
$con = mysql_connect('','','') or die(mysql_error());
$db = mysql_select_db('db', $con);
if(isset($_POST['upload'])&amp;&amp;$_POST['title']&gt;0)
{
$title = $_POST['title'];
$comment = $_POST['comment'];
$fileName = $_FILES['userfile']['name'];
$tmpName  = $_FILES['userfile']['tmp_name'];
$fileSize = $_FILES['userfile']['size'];
$fileType = $_FILES['userfile']['type'];
$fileType=(get_magic_quotes_gpc()==0 ? mysql_real_escape_string(
$_FILES['userfile']['type']) : mysql_real_escape_string(
stripslashes ($_FILES['userfile'])));
$fp      = fopen($tmpName, 'r');
$content = fread($fp, filesize($tmpName));
$content = addslashes($content);
fclose($fp);
if(!get_magic_quotes_gpc())
{
$fileName = addslashes($fileName);
}

if($db){
   $query = "INSERT INTO table (title,comment, name, size, type, content ) ".
 "VALUES ('$title','$comment','$fileName', '$fileSize', '$fileType', '$content')";
mysql_query($query) or die('Error, query failed'); 
mysql_close();
echo "&lt;br&gt;Success: $title &lt;br&gt;";
}else { echo "Error"; }
 } 
?&gt;
</code></pre>
