ok I've searched stackoverflow and many other sites, I've tried all kinds of solutions for this but nothing seems to work.
I am processing a form in PHP, checking for missed entries and erroring if missed or adding to the SQL DB if ok, the form itself works just fine, the processing works, the form is either error thrown and displayed or added to the Database, I want that page to then display either error or sucess wait a short time and then auto forward either back to the form if there was an error, or to the page that displays the db contents if the add was successful. Nothing I seem to try here works. please help: My code so far:
//If errors present
if ($errormsg) {
echo "<div class=\"box red\">$errormsg</div>";
sleep(2);
echo '<script>' . "\n";
echo 'window.location="blogmake.html?blogid=" + blogid;';
echo '</script>';
}
if ($secim == "3"){ //If all present and correct post comment to DB
if ($valname && $valemail && $valcom){
$con = mysql_connect("xxxx","User","pass");
if (!$con)
die('Could not connect: ' . mysql_error());
mysql_select_db("dbname", $con);
$fulcom = mysql_real_escape_string ($_POST['comment']);
mysql_query("INSERT INTO tabname(blogid, date, email, name, comment) VALUES ('$blogid', CURRENT_TIMESTAMP(),'$valemail','$valname','$fulcom')") or die('Error: ' . mysql_error());
mysql_close($con);
echo "<div class=\"box green\">Your comment has been submitted</div>";
sleep(2);
echo '<script>' . "\n";
echo 'window.location="blogread.php?blogid=" + blogid;';
echo '</script>';
}
}
?>
</div>
You need:
Change 3 for your seconds and url= by your webpage, ie: