473,385 Members | 1,154 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Passing Parameters to a Web Page Script

JD
I posted this earlier and it disappeared from the NewsGroup

I want to pass two parameters to a simple script running on my web server.

The script "parpass.php" looks like this:

<?php
echo "The total number of parameters passed was: $argc \n";
echo "The parameters passed were: ";
foreach (argv as $val) {
echo "$val ";
}
echo " \n ";
?>

I tried running this script by typing this in my browser window

http://www.myserver.org/parpass.php parm1 parm2

The script runs but does not report any parameters

Any help would be appreciated.

I'm new to PHP but am getting better.

Thanks to all

John
Jul 17 '05 #1
1 3309
JD wrote:
I posted this earlier and it disappeared from the NewsGroup
I tried running this script by typing this in my browser window>
http://www.myserver.org/parpass.php parm1 parm2
The script runs but does not report any parameters


"Parameters"? HAH! Klingon functions do not have 'parameters'. They have
ARGUMENTS. And they ALWAYS WIN THEM.

But seriously (ahem), there could be two issues here.

1. Assuming that your url example above is literally verbatim, you
appear to be missing the required question mark before the 'parameters'
and the required ampersand between them, with no spaces, thus the
'correct' way to type the url is:

http://www.myserver.org/parpass.php?parm1&parm2

where 'parm1' is 'myvariable1=myvalue1' and 'parm1' is
'myvariable2=myvalue2'.

2. The more fundamental and important problem is that you really
shouldn't be able to do this in the first place.

Run a phpinfo.php script and look for the property called
'register_globals', which, when turned on, allows any values passed
through a url to become automatically recognized as global variables by
default. This is a tremendous security problem, as it allows malicious
users to potentially pass all sorts of values to your script just by
typing in various values in the url.

Since PHP 4.2.0, this property has been turned *off* by default and you
really should leave it that way. In this state, the only way you can
pass values from one script to the next (or to itself, recursively,) is
through forms or hyperlinks that you have coded, and the only way to
retrieve those values is to use the global arrays POST, GET, and REQUEST.

See the following references I posted in a previous thread on this topic:

See the following errata page from Wrox for an explanation (refer to the
second entry on the errata listing):
http://www.wrox.com/books/errata/076...4_errata.shtml

Also see the following documentation on www.php.net (be sure to scroll
to the bottom of the page to the section headed 'SECURITY: NEW INPUT
MECHANISM'):
http://www.php.net/release_4_1_0.php

Also see this page and refer to the big box headed 'Warning':
http://us4.php.net/variables.predefined

Jul 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Kevin Lyons | last post by:
Hello, I am trying to get my select options (courses) passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html I am having difficulty getting the...
3
by: domeceo | last post by:
can anyone tell me why I cannot pass values in a setTimeout function whenever I use this function it says "menu is undefined" after th alert. function imgOff(menu, num) { if (document.images) {...
29
by: wayne | last post by:
Hey there... I'm having some problems passing url parameters with an open.window command. I'm not terribly familiar with java script but here is the code below. When executed it opens the...
4
by: Doruk | last post by:
The problem that we are experiencing is simple: We want to pass certain parameters from a page with several server controls to another page. We want to do this in a dotnet compliant manner,...
4
by: David Freeman | last post by:
Hi There! I'm just wondering if there's a way to pass parameters (as if you were passing parameters to a ASCX web control) when calling an ASPX page? e.g. MyDetailsPage.UserName = "david" ...
1
by: Paul D. Fox | last post by:
I'm trying to launch a Child Window from a hyperlink on a Datagrid and have it recieve multiple values from the Parent Window. Upon recieving the values in the Child Window, I need to access them...
7
by: amygdala | last post by:
Hi all, I'm starting this new project in which I'ld like to implement sort of a design pattern I have seen being used in the CodeIgniter framework. Basically, the site will examine the URI and...
4
by: moondaddy | last post by:
I have a htm page where I need to pass some data to an aspx page as a means of sending data to the database. I don't need to see the aspx page so I was going to put it in a hidden iframe. This...
3
by: pavanip | last post by:
Hi, I have written the code for display popup window using javascript in button onclient click event. <asp:Button ID="Button1" runat="server" Style="position: static"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.