Load another page on refresh

jericko

Newbie
Nov 15, 2008
16
2
I saw on a site a while ago, their index page first shows their registration form, but if you refresh that page, the index appears instead.

How is it possible to do that?
 
This can be done with PHP and sessions. Pretty much what the example below shows is when the page is loaded php initializes a session, then checks to see if the "second_view" session variable has been set to "yes". If it has been set then it will show the code for the index page. If the "second_view" variable is not set then it sets the "second_view" variable to "yes" and displays the registration form.

Create index.php and insert the following code:

Code:
<?php
session_start();

if (isset($_SESSION['second_view']) && $_SESSION['second_view'] == 'yes'){
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Index Page</title>
</head>
<body>
	<div>Your index page would go here</div>
</body>
</html>
<?php
} else {
	$_SESSION['second_view'] = 'yes';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Registration Form</title>
</head>
<body>
	<form action="formpost.php" method="post" enctype="multipart/form-data" >
		<input type="text" name="input1" />
		<br />
		<input type="text" name="input1" />
		<input type="submit" />
	</form>		
</body>
</html>
<?php
}
?>
 
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features and essential functions on BlackHatWorld and other forums. These functions are unrelated to ads, such as internal links and images. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock