Hi
Can anyone help ....
I have some php code that calls a short programme which in turns calls two other files .... Then it goes to a mysql database looks up a few things and decides whether or not to redirect you to another page, or stick with the one you're on ..... thus:
<?
require_once("pcr_val.php");
require_once("pcr_func.php");
db_open();
$sql = @mysql_Fetch_object(mysql_Query("SELECT `ip` FROM `pcr_ips` WHERE `ip`='".$REMOTE_ADDR."'"));
if(!$sql->ip){
$sql = "SELECT country FROM ip2nation WHERE ip < INET_ATON('".$REMOTE_ADDR."') ORDER BY ip DESC LIMIT 0,1";
$country = mysql_result(mysql_query($sql), 0, 0);
setcookie("user_country", $country, time()+3600);
$sql = mysql_fetch_object(mysql_query("SELECT * FROM `pcr_countries` WHERE `code`='$country'"));
db_close();
if(($sql->status == 1)&&($sql->outpage <>"")){
header("Location: $sql->outpage");
}
}
?>
*************pcr_val.php
<?php
$mysql_host = 'localhost';
$mysql_db = 'dog';
$mysql_user = 'dog';
$mysql_pass = '999';
?>
*************pcr_func.php
<?
function db_open() {
global $mysql_host, $mysql_user, $mysql_pass, $mysql_db, $mysql_link;
$mysql_link = mysql_connect($mysql_host,$mysql_user,$mysql_pass) or print mysql_error();
mysql_select_db($mysql_db) or print mysql_error();
}
function db_close() {
global $mysql_link;
@mysql_close($mysql_link) or print mysql_error();
}
?>
Does anyone know of a way I could turn the above into a single javascript, which I could insert into .html pages, with it doing the same thing?
Would be interested in any help
Thanks
Guy