28, May 2012

parameter passing - webmaster forum

 
Webdigity webmaster forums
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: parameter passing
« previous next »
Pages: [1] Print
Instabuck - The easy way to sell digital products online

Author Topic: parameter passing  (Read 2653 times)
Global Moderator
Internet Junkie
*****
Gender: Male
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...


Last blog : Are You Stumbling Yet?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: Jun 18, 2006, 08:38:10 pm »

I wrote a small script for this:

http://www.finalwebsites.com/snippets.php?id=34

but its better to show the code you have (not the whole page, just the piece of php code) Wink

Global Moderator
Internet Junkie
*****
Gender: Male
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!


Last blog : Are You Stumbling Yet?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: Jun 18, 2006, 09:06:19 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!


Yes it sounds like that "register_globals = off",

you need to use $_GET['M'] in place of $M

Global Moderator
Internet Junkie
*****
Gender: Male
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!


Last blog : Are You Stumbling Yet?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #5 on: Jun 18, 2006, 10:30:22 pm »

aha, that simple? I'll give it a try later. Thanks!
yes that simple, hehe Cheesy

EDIT: check this info from the manual: http://nl2.php.net/register_globals

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #6 on: Jun 19, 2006, 11:27:01 am »

You can also try $_REQUEST['M'] (works both with GET and POST variables) but anyway your production server should have registered globals

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #7 on: Jun 19, 2006, 11:29:40 am »

... but anyway your production server should have registered globals
Why?, you get buggy applications if you program for register_globals = on

I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 5799
46391 credits
Members referred : 3



« Reply #8 on: Jun 19, 2006, 11:31:54 am »

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.

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #9 on: Jun 19, 2006, 11:42:18 am »

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... Wink

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: Male
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

Trial and Error my two best teachers Cool
Join us @ facebook or twitter

Last blog : Butterfly Marketing 2.0
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6691
34714 credits
Members referred : 374


It's time to use PHP5!


« Reply #11 on: Jun 19, 2006, 12:05:09 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
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
Tags : php html cookies Bookmark this thread : Digg Del.icio.us Dzone more....

Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  PhP
Topic: parameter passing
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
May 28, 2012, 01:18:44 pm





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!






Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2012 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.