Script not working with Firefox but working ok with IE

Hi, the following work well with IE but not for Firefox.

When you select a link the following code get called and log the hit from the url then redirect to the url selected.
With firefox a black page with Redirecting show up with the url but you have to click on it to go there.

I would like go directly to the url with having to click on the link.

Thank You.



<html><body text=#ffffff bgcolor=000000 onLoad="javascript:document.links[0].click();">
<?
# pointer.php
# passed vars: g
# this page will redirect a user to the specified url
#
# NOTE: $g can only be accessed if register globals is turned on (not suggested)
$destination = base64_decode(urldecode($_GET['g'])); // $_GET['g']);

// find the link in the video table so we can log the hit...
// j require_once 'init/nom_var.php';
// j require_once 'init/init.php';
require_once ($DOCUMENT_ROOT . "/init/nom_var.php");
require_once ($DOCUMENT_ROOT . "/init/init.php");
$sql = 'SELECT
            VI_ID,
            VI_category
        FROM
            video
        WHERE
            VI_url = \'' . addslashes($destination) . '\'';
$query = mysql_query($sql);
$rowID = @mysql_result($query, 0, 0);
$category = @mysql_result($query, 0, 1);

if (preg_match('/^\d+$/', $rowID)) {
    // A valid record was found.  Now log the hit
    $sql = 'INSERT INTO video_access_log (
                VAL_VI_ID,
                VAL_category,
                VAL_lang,
                VAL_accessdate)
            VALUES(
                ' . $rowID . ',
                \'' . addslashes($category) . '\',
                \'eng\',
                NOW())';
    $query = mysql_query($sql);
}
?>
<a name=redirect href="<? echo $destination; ?>"> Redirecting...</a>
 </body></html>
olivierarbezAsked:
Who is Participating?
 
kamermansCommented:
Or you can make the redirection seamless:

<?php //this is the first line of your page
# pointer.php
# passed vars: g
# this page will redirect a user to the specified url
#
# NOTE: $g can only be accessed if register globals is turned on (not suggested)
$destination = base64_decode(urldecode($_GET['g'])); // $_GET['g']);

// find the link in the video table so we can log the hit...
// j require_once 'init/nom_var.php';
// j require_once 'init/init.php';
require_once ($DOCUMENT_ROOT . "/init/nom_var.php");
require_once ($DOCUMENT_ROOT . "/init/init.php");
$sql = 'SELECT
            VI_ID,
            VI_category
        FROM
            video
        WHERE
            VI_url = \'' . addslashes($destination) . '\'';
$query = mysql_query($sql);
$rowID = @mysql_result($query, 0, 0);
$category = @mysql_result($query, 0, 1);

if (preg_match('/^\d+$/', $rowID)) {
    // A valid record was found.  Now log the hit
    $sql = 'INSERT INTO video_access_log (
                VAL_VI_ID,
                VAL_category,
                VAL_lang,
                VAL_accessdate)
            VALUES(
                ' . $rowID . ',
                \'' . addslashes($category) . '\',
                \'eng\',
                NOW())';
    $query = mysql_query($sql);
}
header("Location: $destination");
?>
0
 
kamermansCommented:
Try this:

<html><body text="#ffffff" bgcolor="000000">
<?php
# pointer.php
# passed vars: g
# this page will redirect a user to the specified url
#
# NOTE: $g can only be accessed if register globals is turned on (not suggested)
$destination = base64_decode(urldecode($_GET['g'])); // $_GET['g']);

// find the link in the video table so we can log the hit...
// j require_once 'init/nom_var.php';
// j require_once 'init/init.php';
require_once ($DOCUMENT_ROOT . "/init/nom_var.php");
require_once ($DOCUMENT_ROOT . "/init/init.php");
$sql = 'SELECT
            VI_ID,
            VI_category
        FROM
            video
        WHERE
            VI_url = \'' . addslashes($destination) . '\'';
$query = mysql_query($sql);
$rowID = @mysql_result($query, 0, 0);
$category = @mysql_result($query, 0, 1);

if (preg_match('/^\d+$/', $rowID)) {
    // A valid record was found.  Now log the hit
    $sql = 'INSERT INTO video_access_log (
                VAL_VI_ID,
                VAL_category,
                VAL_lang,
                VAL_accessdate)
            VALUES(
                ' . $rowID . ',
                \'' . addslashes($category) . '\',
                \'eng\',
                NOW())';
    $query = mysql_query($sql);
}
javascriptRedir($destination,2); //set the number to 0 to redirect immediately

function javascriptRedir($page, $seconds){
      $time = $seconds * 1000;
      echo "<br><br>You will be redirected to <a href='$page'>$page</a> in $seconds seconds...";
      echo '<script language="javascript">'."\n".'setTimeout('."'".'window.location.href = "'.$page.'"'."'".', '.$time.');'.'</script>';
}
?>
 </body></html>
0
 
olivierarbezAuthor Commented:
The script is working but could you please remove the time function  so it redirect right away (I am aware that 0 will redirect immediately).

Thank you
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
RoonaanCommented:
I would use:

<?php //this is the first line of your page
# pointer.php
# passed vars: g
# this page will redirect a user to the specified url
#
# NOTE: $g can only be accessed if register globals is turned on (not suggested)
$destination = base64_decode(urldecode($_GET['g'])); // $_GET['g']);

// find the link in the video table so we can log the hit...
// j require_once 'init/nom_var.php';
// j require_once 'init/init.php';
require_once ($DOCUMENT_ROOT . "/init/nom_var.php");
require_once ($DOCUMENT_ROOT . "/init/init.php");
$sql = 'SELECT
            VI_ID,
            VI_category
        FROM
            video
        WHERE
            VI_url = \'' . addslashes($destination) . '\'';
$query = mysql_query($sql);
$rowID = @mysql_result($query, 0, 0);
$category = @mysql_result($query, 0, 1);

if (preg_match('/^\d+$/', $rowID)) {
    // A valid record was found.  Now log the hit
    $sql = 'INSERT INTO video_access_log (
                VAL_VI_ID,
                VAL_category,
                VAL_lang,
                VAL_accessdate)
            VALUES(
                ' . $rowID . ',
                \'' . addslashes($category) . '\',
                \'eng\',
                NOW())';
    $query = mysql_query($sql);
}
?>
<html><body onload="window.location='<?php echo htmlspecialchars($destination);?>';">
You are being redirected. When nothing happens please click this link: <a name=redirect href="<?php echo htmlspecialchars($destination); ?>"><?php echo htmlspecialchars($destination);?></a>
</body>

-r-
</html>

0
 
olivierarbezAuthor Commented:
Both of the solution works. I will have to Split points.

Is it possible to add a referrer variable to a header? like $referrer that would be sent with the URL $destination.

Thank you.

-O-
0
 
kamermansCommented:
$ref = urlencode($_SERVER['HTTP_REFERRER']);
header("Location: $destination?ref=$ref");

Then just use this to get the referrer back in the next script: $ref = urldecode($_GET['ref']);
0
 
olivierarbezAuthor Commented:
Thank you for your great help.

-O-
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.