Sunday, 11 August 2013

Form get's resent on refresh

Form get's resent on refresh

Form get's resent on refresh, I had read about
header("Location:my_page.php") unset($_POST), but I'm not sure where to
place it :( ... This is our script, it works as need it, but it keeps
re-sending on page refresh (Chrome browser alerts over and over), can some
one fix the code and explain to my like 2 years old child :p .. please -
thanks :) .
<?php
if (isset($_POST['submit']))
{
mysql_connect("localhost", "root", "toor") or die("Error connecting to
database: " . mysql_error());
mysql_select_db("db_name") or die(mysql_error());
$query = $_POST['query'];
$min_length = 2;
if (strlen($query) >= $min_length)
{
$query = htmlspecialchars($query);
$query = mysql_real_escape_string($query);
echo "";
$result = mysql_query("SELECT *, DATE_FORMAT(lasteditdate,
'%m-%d-%Y') AS lasteditdate FROM movies WHERE (`moviename`
LIKE '%" . $query . "%') OR (`year` LIKE '%" . $query . "%')")
or die(mysql_error());
if (mysql_num_rows($result) > 0)
{
while ($results = mysql_fetch_array($result))
{
echo "";
}
}
else
{
echo "";
}
}
else
{
echo "";
}
}
?>

No comments:

Post a Comment