Jump to content

[SOLVED] URL Redirection Problem


wwfc_barmy_army

Recommended Posts

Hello.

 

I have this code, i have modified a script already available:

 

<?php

ob_start();
include("config.php"); 
if(isset($_GET['id'])) {
$gid = mysql_real_escape_string($_GET['id']);
$qs = mysql_query("SELECT url FROM $table WHERE tag = '$gid';") or die('MySQL error: '.mysql_error());
if (mysql_num_rows($qs) == 0) {
	$qs = mysql_query("SELECT url FROM $table WHERE `id` = $gid;") or die('MySQL error: '.mysql_error());
	mysql_query("UPDATE url SET count=(count + 1) WHERE `id` = $gid;") or die('MySQL error: '.mysql_error());
} else
	mysql_query("UPDATE url SET count=(count + 1) WHERE `tag` = '$gid';") or die('MySQL error: '.mysql_error());
while($data = mysql_fetch_array($qs)) {
	if ($frame == 1) {
		include("frame.php");
		echo "<iframe name=\"pagetext\" height=\"100%\" frameborder=\"no\" width=\"100%\" src=\"$data[0]\"></iframe>";
	} else if ($frame == 0) {
	echo $data[0];
	?>
        <SCRIPT LANGUAGE="JavaScript">
<!-- Original:  Corey ([email protected] ) -->
<!-- Web Site:   http://six38.tripod.com -->
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
var start=new Date();
start=Date.parse(start)/1000;
var counts=10;
function CountDown(){
	var now=new Date();
	now=Date.parse(now)/1000;
	var x=parseInt(counts-(now-start),10);
	if(document.form1){document.form1.clock.value = x;}
	if(x>0){
		timerID=setTimeout("CountDown()", 100)
	}else{
		 <?php
		header("Location: $data[0]");
		?>
	}
}
//  End -->
</script>
<SCRIPT LANGUAGE="JavaScript">
<!--
window.setTimeout('CountDown()',100);
-->
</script>

        
        
        <SCRIPT LANGUAGE="JavaScript">
<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->
<!-- Begin
// Cache-busting LUBID bug.
var ran = Math.round(Math.random() * 899999) + 100000;
var lubid_string = "<img src=\"http://lubid.lycos.com/one.asp?site=members.tripod.lycos.com&ord=" + ran + "\" height=\"1\" width=\"1\">";
document.write(lubid_string);
//
//  End -->
</script>
</center>
<FORM NAME="form1">
You are being redirected in 
<INPUT TYPE="text" NAME="clock" SIZE="2" VALUE="10"> 
seconds.
</FORM>
</center>
        
        <?php
		//echo header("Location: $data[0]");
	}
}
}

ob_flush();
?>

 

After 10 seconds it should do the 'else', which is the header redirect. Although it's just doing it straight away without waiting the 10 seconds. Any ideas?

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/117937-solved-url-redirection-problem/
Share on other sites

Don't mix JavaScript and PHP like that.

 

PHP = Server Side

JS = Client Side

 

Why not just use the javascripts window.location to redirect?

 

He is right.

You can't put a php header redirect right there.. what happens is when PHP checks the code first, it doesnt care about the JavaScript and will just run the code

You will need to use a JavaScript redirect (window.location)

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.