P
pettere
Guest
How do I redirect visitors to other website URL's using this simple PHP script? Can I exchange the ECHO function for some sort of redirect function? Is it possible to redirect using the HEADER function? Or can that function not be used within the script?
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// random number 1 - 100
$result_random=rand(1, 100);
// if result less than or equal 70, display ad 1 (70%)
if($result_random<=70){
echo "Display ad1";
}
// if result less than or equal 90, display ad 2 (20%)
elseif($result_random<=90){
echo "Display ad2";
}
// if result less than or equal 100, display ad 3 (10%)
elseif($result_random<=100){
echo "Display ad3";
}
?>
</body>
</html>
<!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=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
// random number 1 - 100
$result_random=rand(1, 100);
// if result less than or equal 70, display ad 1 (70%)
if($result_random<=70){
echo "Display ad1";
}
// if result less than or equal 90, display ad 2 (20%)
elseif($result_random<=90){
echo "Display ad2";
}
// if result less than or equal 100, display ad 3 (10%)
elseif($result_random<=100){
echo "Display ad3";
}
?>
</body>
</html>