Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« on: Jun 18, 2006, 06:19:23 pm »
I'm building a page with links, to track the number of times each link was clicked the idea was to use a script in a new window. The links on the page would link to /out.php?L=1 where L is different for each link. the out.php gets the URL from a DB updates the click-counter and opens the link. I've done scripts with parameters like this before, but for some reason it doesn't work this time. Is there any other/better way to track the number of klicks on a link?
P.S. My script is working fine on my server, but the parameters are not filled on the server that is running this website...
but its better to show the code you have (not the whole page, just the piece of php code)
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #2 on: Jun 18, 2006, 08:57:32 pm »
The code I'm trying to use is:
Code:
$parm_test = $M;
The url of the page would be like this: www.page.com/click.php?M=3 This should fill $parm_test in the script with the value 3 and it works fine on my own server, but not on the server my client uses to host his site... I guess his host has something disabled. I'll have a look at your code later Olaf, Thanks!
The url of the page would be like this: www.page.com/click.php?M=3 This should fill $parm_test in the script with the value 3 and it works fine on my own server, but not on the server my client uses to host his site... I guess his host has something disabled. I'll have a look at your code later Olaf, Thanks!
Yes it sounds like that "register_globals = off",
you need to use $_GET['M'] in place of $M
Global Moderator
Internet Junkie
Gender:
Posts: 1807
9006 credits Members referred : 6
« Reply #4 on: Jun 18, 2006, 10:18:55 pm »
aha, that simple? I'll give it a try later. Thanks!
Why is that? (I have heared that before, but I don't understand the reason for this)
The only thing that you have to do when register_globals=on is to addslashes() to the vaiables you are using.
programming with register_globals = on is old fashioned...
example I think its important to know if a variable is send by post, get or is just a session or cookie. And you need to write more save code like:
Code:
<?php $sql = sprintf("SELECT * FROM table WHERE id = %d", $_GET['some_var']);
an I think that this will say enough: (from the manual)
When on, register_globals will inject (poison) your scripts will all sorts of variables, like request variables from HTML forms. This coupled with the fact that PHP doesn't require variable initialization means writing insecure code is that much easier. It was a difficult decision, but the PHP community decided to disable this directive by default. When on, people use variables yet really don't know for sure where they come from and can only assume. Internal variables that are defined in the script itself get mixed up with request data sent by users and disabling register_globals changes this.
I am a metal monkey!
Administrator Community Supporter?
Jedai Sword Master
Gender:
Posts: 5799
46391 credits Members referred : 3
« Reply #10 on: Jun 19, 2006, 12:00:11 pm »
You are right it is old fashioned and it is easier to make insecure code with registered globals, but if you know the possible problems, it is ok to use them
You are right it is old fashioned and it is easier to make insecure code with registered globals, but if you know the possible problems, it is ok to use them
I thought the same, some years before and afterwards I update all code. Most of the time I run websites where this setting is "on" but for my development platform the value is always "off".
At last think about an application where the webhost is changed after a few years..
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=2924