Jump to content

Recommended Posts

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.

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>

 

 

<?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.

<?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

 

 

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>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.