• Howdy! Welcome to our community of more than 130.000 members devoted to web hosting. This is a great place to get special offers from web hosts and post your own requests or ads. To start posting sign up here. Cheers! /Peo, FreeWebSpace.net
managed wordpress hosting

PHP help

Faraz

Active Member
The following code executes perfectly on the apache server installed on my PC, but it doesn't work when I upload to a webhost. I mean the page with the following code doesn't load up at all. Can you help?

<?
session_start();
session_register( "session" );
session_register( "hits" );
session_register( "codenumber" );
$session=session_id();
if ($code==$codenumber)
{
if ($HTTP_REFERER=="http://localhost/ute/main.php")
{
if ($B1=="Next Site")
{
$hits++;
}
}
else
{
header("Location: main.php");
}
}
?>
<html>

<head>
<title>New Page 1</title>
<SCRIPT>
var interval = "";
var i = 20;
var cn=<? print $codenumber=rand(1,1000);?>;
function EnableSubmit(whichButton)
{
if (document.getElementById)
{
// this is the way the standards work
document.getElementById(whichButton).disabled = false;
}
else if (document.all)
{
// this is the way old msie versions work
document.all[whichButton].disabled = false;
}
else if (document.layers)
{
// this is the way nn4 works
document.layers[whichButton].disabled = false;
}
}

function startInterval()
{
interval = window.setInterval("tTimer()",1000);
}
function stopInterval()
{
window.clearInterval (interval);
interval="";
}
function tTimer()
{
document.f.display.value = i--;
if (i == -1)
{
stopInterval();
EnableSubmit('mFormSubmit');
f.code.value=cn;
}
}
</script>
</head>

<body>

<form name="f" action="main.php" method=post>
<p><input type="text" name="display" value size="2"><?print " Hits registered: $hits";?>
<p><input type="submit" value="Next Site" id="mFormSubmit" name="B1" disabled>
<input type="hidden" name="code">
</form>
<script>
startInterval();
</script>
<form method="POST" action="done.php">
<p><input type="submit" value="Done" name="B2"></p>
</form>
<p align="center"><IFRAME src="frame.php" height="500" width="800">
</IFRAME></p>

</body>
</html>

Sorry, if you find it scattered and messy. :rolleyes2
 
Not all servers support <?. Try changing that to <?php.

Otherwise, it could be php version. Check for differences.
 
i think if you change the HTTP refferer then it may work.

Find this:
Code:
http://localhost/ute/main.php

Change it to :
Code:
http://www.yourdomain.com/ute/main.php

As its a condition there it might get your script work. I m not sure as not all the things can understand from this script only.

Regards
 
Yeah, you are right. It's a php version. :(

Could you tell me how can I register variables in PHP 4.4.1 with register_globals off. session_register doesn't seem to work. Also how could I get the value of $HTTP_REFERER?
 
($HTTP_REFERER=="http://localhost/ute/main.php")

Here is the value of HTTP_REFFERER

And about the register_globals Off you may contact with your hosters to enable it. Just need to edit the php.ini file and need to set the value of $register_globals to "on".

regards
 
No, I mean when I type print $HTTP_REFERER; it doesn't give anything in PHP 4.4.1.

I found the way to register variables with register_globals off though.
 
No, I mean when I type print $HTTP_REFERER; it doesn't give anything in PHP 4.4.1.

Untill there are any refferer how the http_referer will print a value?? Use the following script:

Code:
<?php
if ($HTTP_REFERER) {
echo $HTTP_REFERER;
} else {
echo "No Referer";
}
?>

This will echo no referer if there are no referer of you page.

Regards
 
you might wanna try inserting this code on top of your page:


Code:
if(!empty($_GET)) extract($_GET);
if(!empty($_POST)) extract($_POST);

Works for me when register globals is set to off...
 
egomac said:
you might wanna try inserting this code on top of your page:


Code:
if(!empty($_GET)) extract($_GET);
if(!empty($_POST)) extract($_POST);

Works for me when register globals is set to off...
This will not generate the value of referer. Only extract the get and post informations before getting into the script. Therefore it requires no register global enabling.
 
Back
Top