Php

Status
Not open for further replies.

bobshandel

New Member
Messages
22
Reaction score
0
Points
0
Hey, I was wondering if anybody could help me out with this. I wrote up a simple PHP script to test something, and it seems that something is wrong. The script was

PHP:
<?php
echo "Thank you " . $n . " for your IP! (" . $_SERVER["REMOTE_ADDR"] . ")<hr><br>";
?>

So $n is declared in the url, and should change accordingly.

So I uploaded it and the URL is http://programz.info/testing.php?n=blah , but the variable n doesn't seem to show. So I made sure my script was right by uploading at another PHP enabled host at http://members.lycos.co.uk/myspace123/testing.php?n=blah and declaring that n=blah in the url does work. So I was wondering if anybody could help me out with this problem, thanks.
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
If you want a reason..

Bryon said:
The problem is that you're relying on register_globals to be enabled, which is not a good thing.

You need to access variables from GET\POST using the superglobal arrays. ($_GET\$_POST)
http://us2.php.net/register_globals

Example of what you'll need to do:
PHP:
<?php

   $n = $_GET['n'];
   $n = preg_replace('#[^a-zA-Z0-9]#', '', $n); // Need to be safe.
   echo 'Thank you '. $n .' for your IP! (' . $_SERVER['REMOTE_ADDR'] .')<hr><br />';

?>
 
Status
Not open for further replies.
Top