zgkhoo Posted August 18, 2007 Share Posted August 18, 2007 eg echo "testing"; echo "testing"; echo "testing"; echo "testing"; echo "testing"; if(isset($_REQUEST['button'])){ //what should put in here to refresh the page? } Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/ Share on other sites More sharing options...
jscix Posted August 18, 2007 Share Posted August 18, 2007 PHP can't refresh the page, but it can redirect back, to the same page header("Location: page.html"); You can do it in javascript easily, though. oh. Also.. if your using the Header code, nothing can be outputted before-hand. It has to come before any data is sent to the browser. Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-327522 Share on other sites More sharing options...
zgkhoo Posted August 19, 2007 Author Share Posted August 19, 2007 then how to set the countdown time eg 20second..then auto redirect to another page? php can achieve that or not? thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-327881 Share on other sites More sharing options...
dbillings Posted August 19, 2007 Share Posted August 19, 2007 <?php sleep(20);//seconds to wait.. header("Location:http://www.domain.com"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-327885 Share on other sites More sharing options...
cha0sriderx Posted August 19, 2007 Share Posted August 19, 2007 i dont think you can redirect in php with data already sent but u can use java script. echo '<script type="text/javascript">window.location = "PAGE LINK"</script>'; Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-327894 Share on other sites More sharing options...
zgkhoo Posted August 19, 2007 Author Share Posted August 19, 2007 this code seem dont have countdown time for redirect. thanks.. Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-327913 Share on other sites More sharing options...
phpQuestioner Posted August 19, 2007 Share Posted August 19, 2007 try this: <script language="javascript"> function redirect() { document.location.href="mypage.html"; } window.onload=function() { setTimeout("redirect()", 20000); } </script> <noscript> // use this in case javascript is turned off <META HTTP-EQUIV=Refresh CONTENT="20; URL=mypage.html"> </noscript> Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-327914 Share on other sites More sharing options...
Daniel0 Posted August 19, 2007 Share Posted August 19, 2007 <?php sleep(20);//seconds to wait.. header("Location:http://www.domain.com"); ?> That'll just increase the load time because the page will not be presented to the user before the script is finished executing. If set it to sleep for 20 seconds then it'll just take 20 seconds more before the page loads. Do as said in the post above me. Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-327922 Share on other sites More sharing options...
phpQuestioner Posted August 19, 2007 Share Posted August 19, 2007 If your going the PHP way; you could also use a header refresh. <?php $whereiamat = $_SERVER['PHP_SELF']; header("refresh: 20; url=$whereiamat"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-327924 Share on other sites More sharing options...
zgkhoo Posted August 25, 2007 Author Share Posted August 25, 2007 <?php session_start(); if(isset($_POST["ic"])) { $_SESSION["ic"] = $_POST["ic"]; } if(isset($_POST["fullname"])) { $_SESSION["fullname"] = $_POST["fullname"]; } if(isset($_POST["gender"])) { $_SESSION["gender"] = $_POST["gender"]; } if(isset($_POST["dob"])) { $_SESSION["dob"] = $_POST["dob"]; } if(isset($_POST["address"])) { $_SESSION["address"] = $_POST["address"]; } if(isset($_POST["postcode"])) { $_SESSION["postcode"] = $_POST["postcode"]; } if(isset($_POST["city"])) { $_SESSION["city"] = $_POST["city"]; } if(isset($_POST["state"])) { $_SESSION["state"] = $_POST["state"]; } if(isset($_POST["phonenumber"])) { $_SESSION["phonenumber"] = $_POST["phonenumber"]; } if(isset($_POST["hpnumber"])) { $_SESSION["hpnumber"] = $_POST["hpnumber"]; } if(isset($_POST["banktype"])) { $_SESSION["banktype"] = $_POST["banktype"]; } if(isset($_POST["accname"])) { $_SESSION["accname"] = $_POST["accname"]; } if(isset($_POST["accnumber"])) { $_SESSION["accnumber"] = $_POST["accnumber"]; } //$_SESSION["gender"] = $_POST["gender"]; //$_SESSION["address"] = $_POST["address"]; //$_SESSION["postcode"] = $_POST["postcode"]; //$_SESSION["city"] = $_POST["city"]; //$_SESSION["state"] = $_POST["state"]; //$_SESSION["phonenumber"] = $_POST["phonenumber"]; //$_SESSION["hpnumber"] = $_POST["hpnumber"]; //$_SESSION["banktype"] = $_POST["banktype"]; //$_SESSION["accname"] = $_POST["accname"]; //$_SESSION["accnumber"] = $_POST["accnumber"]; //store data into variable echo "<br>"; echo "Username = "; echo $_SESSION["username"]; echo "<br>"; echo "Password = "; echo $_SESSION["password"]; echo "<br>"; echo "Country = "; echo $_SESSION["country"]; echo "<br>"; echo "IC = "; echo $_SESSION["ic"]; echo "<br>"; echo "Fullname = "; echo $_SESSION["fullname"]; echo "<br>"; echo "Gender = "; echo $_SESSION["gender"]; echo "<br>"; echo "DOB = "; echo $_SESSION["dob"]; echo "<br>"; echo "Address = "; echo $_SESSION["address"]; echo "<br>"; echo " Postcode= "; echo $_SESSION["postcode"]; echo "<br>"; echo "City = "; echo $_SESSION["city"]; echo "<br>"; echo "State = "; echo $_SESSION["state"]; echo "<br>"; echo "Phone Number = "; echo $_SESSION["phonenumber"]; echo "<br>"; echo "HP Number = "; echo $_SESSION["hpnumber"]; echo "<br>"; echo "BankYype = "; echo $_SESSION["banktype"]; echo "<br>"; echo "Account Name = "; echo $_SESSION["accname"]; echo "<br>"; echo "Account Number = "; echo $_SESSION["accnumber"]; echo "<br>"; echo "Card ID= "; echo $_SESSION["cardID"]; echo "<br>"; echo "Upline ID= "; echo $_SESSION["uplineID"]; if(isset($_REQUEST['button'])) { echo "<BR/>"."Thank you for your registration"; $con = mysql_connect("localhost","root",""); mysql_select_db("my_db", $con); $sql = "CREATE TABLE person ( Username varchar(13), Password varchar(13), Country varchar(10), IC varchar(13), FullName varchar(40), Gender varchar(15), DOB varchar(15), Address varchar(80), Postcode varchar(10), City varchar(20), State varchar(20), PhoneNumber varchar(15), HpNumber varchar(15), BankType varchar(30), AccName varchar(40), AccNumber varchar(15) )"; mysql_query($sql,$con); //insert into table $sql="INSERT INTO person (Username,Password,Country,IC,FullName,Gender,DOB,Address,Postcode,City,State,PhoneNumber,HpNumber,BankType,AccName,AccNumber) VALUES ('$_SESSION[username]','$_SESSION[password]','$_SESSION[country]', '$_SESSION[ic]','$_SESSION[fullname]','$_SESSION[gender]','$_SESSION[dob]', '$_SESSION[address]','$_SESSION[postcode]','$_SESSION[city]','$_SESSION[state]', '$_SESSION[phonenumber]','$_SESSION[hpnumber]','$_SESSION[banktype]', '$_SESSION[accname]','$_SESSION[accnumber]')"; mysql_query($sql,$con); echo "</br>"; echo "<a href=\"main.php\">back to main </a>"; //begin checking card id $cardID=$_SESSION["cardID"]; $result = mysql_query("SELECT * FROM gamecard where Serialnum='$cardID'") or die('Query failed: ' . mysql_error()); $numrows=mysql_num_rows($result); // If we have no results, offer a google search as an alternative if ($numrows == 0) { echo "testing3"; echo "<p>Sorry, your search: "" . $trimmed . "" returned zero results</p>"; } else{ echo "testing4"; echo "cardID=".$cardID; while($row = mysql_fetch_array($result,MYSQL_ASSOC)){ $serial=$row["Serialnum"]; echo "serial=".$serial; echo "ic=".$_SESSION[ic]; } echo "testing5"; mysql_query("UPDATE gamecard SET `Ownerid`= '{$_SESSION['ic']}' WHERE Serialnum =$cardID") or die(mysql_error()); echo "testing6"; echo "UPDATE gamecard SET Ownerid = '".$_SESSION['ic']."' where Serialnum ='$cardID'"; } //refresh page and redirect to main.php $whereiamat = $_SERVER['PHP_SELF']; <---problem at here.. header("refresh: 20; url=$whereiamat"); }//end of isset ?> <html> <body> <form name='noname' action='register3.php' method=post> <input type="submit" name='button' value='comfirm'> </form> </body> </html> Warning: Cannot modify header information - headers already sent by (output started at C:\xampp\htdocs\register3.php:84) in C:\xampp\htdocs\register3.php on line 233 Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-333871 Share on other sites More sharing options...
MadTechie Posted August 25, 2007 Share Posted August 25, 2007 A Javascript solution will probably work best, for a simple count down <script language="javascript"> var count = 20; function countdown() { document.getElementById('countdown').innerHTML = count; count = count-1; if(count == 0) { document.location.href="NewPage.html"; } } </script> <body onload="setInterval('countdown();', 1000);"> <div id="countdown"> </div> </body> Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-333872 Share on other sites More sharing options...
phpSensei Posted August 25, 2007 Share Posted August 25, 2007 USE META... <?php echo "Refreshing..."; echo "<META HTTP-EQUIV='refresh' content='0;URL=http://PAGE YOU NEED TO REFRESG.com'>"; ?> Its slows down the redirect, so you can echo a message before it... Quote Link to comment https://forums.phpfreaks.com/topic/65593-how-to-refresh-a-html-page-using-php/#findComment-333955 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.