I have a php which would check for certain value if it exists in a mysql database. If the value does not exists, it would simply add the value and refresh the page once to load the page again and now it has a value in the database, would go ahead to add other values. How do I refresh page just once when it is called ?
<?php $sname = "W3 schools C# tutorials";//$_POST["sitename"]; $stype = "C#";//$_POST["sitetype"]; $saddy = "www.w3schools.com";//$_POST["siteaddress"]; $scomm = "W3 schools C# tutorials";//$_POST["sitecomment"]; $conn = mysql_connect("localhost","root","password"); if(!$conn){ die("Could not connect: ".mysql_error()); } else { mysql_select_db("bookmarks",$conn); $rs = mysql_query("select TypeId from bookmarktypes where TypeName = '$stype'"); $row = mysql_fetch_array($rs); if($row > 0 ){ //Data found, continue to add... } else { //No data... insert a valid one $rs = mysql_query("insert into bookmarktypes (TypeName) values ('$stype')"); if (!$rs){ die('Error: ' . mysql_error()); } else { //echo "inserted new type data..."; } //echo "</html>"; } } mysql_close($conn); //Refresh page once ?> There's the comment to refresh page below after mysql close command.