?
Solved

Script not working with Firefox but working ok with IE

Posted on 2006-05-09
7
Medium Priority
?
204 Views
Last Modified: 2013-12-12
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>
0
Comment
Question by:olivierarbez
  • 3
  • 3
7 Comments
 
LVL 13

Expert Comment

by:kamermans
ID: 16645418
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
 

Author Comment

by:olivierarbez
ID: 16645608
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
 
LVL 49

Assisted Solution

by:Roonaan
Roonaan earned 600 total points
ID: 16645910
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 13

Accepted Solution

by:
kamermans earned 1400 total points
ID: 16648151
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
 

Author Comment

by:olivierarbez
ID: 16651267
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
 
LVL 13

Expert Comment

by:kamermans
ID: 16654550
$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
 

Author Comment

by:olivierarbez
ID: 16672498
Thank you for your great help.

-O-
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses
Course of the Month17 days, 6 hours left to enroll

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question