faqts : Computers : Programming : Languages : PHP : Common Problems : Forms and User Input : URLs and Post or Get Methods

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

18 of 28 people (64%) answered Yes
Recently 5 of 10 people (50%) answered Yes

Entry

Why does when I write stg like <A href="b.php?parm=myparm"> in a html, the $parm var is void in b.php script? it should be $parm="myparm" isn't it
I'm just trying a simple link between a html file and a php script with an url get method. http_get_
Thanks a lot Mike. It works fine now.
Just a question yet: what's the meanning of the
two dots before and after get_vars in your example?

May 12th, 2008 20:35
i can do it, Mike Boucher, Dom Galli,


The dot operator is used to concatenate strings. In this case the 
string "This is the original value passed: " and the string contained 
in the variable. It is much like the "+" operator in JavaScript.
Example:
<?
$Fname = "Dom";
$Lname = "Galli";
$name = $Fname.$Lname;
echo $name;
?>
Will produce the string "DomGalli", however this isn't 
formatted "correctly" for display so we would want to concatenate the 
first and last name with a space between them.
$name = $Fname." ".$Lname;
           ^    ^    ^--string three (Galli)
           |    +--string two (the space)
           +--string one (Dom)
Which would produce "Dom Galli"
To read more about string functions and operators check out:
http://www.php.net/manual/en/language.types.string.php
http://www.php.net/manual/en/language.operators.string.php
Good Luck
-----
Right, so in the html file you have a list of links that pass $parm to 
b.php
<A href="b.php?parm=lazy">lazy</A><BR>
<A href="b.php?parm=fierce">fierce</A><BR>
<A href="b.php?parm=fat">fat</A><BR>
<A href="b.php?parm=old">old</A><BR>
. . . . more content etc. . . .
Then lets say in your b.php file you simply want to print $parm to 
the browser, have a function that uses $parm in a sentence and 
also prints the new sentence to the browser.
<?
     echo  "This is the original value passed: 
".$HTTP_GET_VARS["parm"]."<BR>";
function myParmFunction()
{
global $HTTP_GET_VARS;
     echo "This is the new string using the variable parm. The red 
fox jumped over the ".$HTTP_GET_VARS["parm"]." brown dog.";
}
    myParmFunction(); 
?>
If you were to click on the link "lazy" then b.php would produce:
This is the original value passed: lazy
This is the new string using the variable parm. The red fox jumped 
over the lazy brown dog. 
Hope this clears it up for you.
Good Luck!
--------------
If you are using $parm inside of a function then you have to declare 
it as a global variable. Also try $HTTP_GET_VARS["parm"].
Good Luck!
http://www.stupidarticles.com
http://www.halazona.com
http://www.shikapika.com
http://www.stakoza.com
http://www.uploadarticles.com
http://www.ganazat.com
http://www.damima.com
http://www.tarabiza.com
http://www.articlesxarticles.com
http://www.articlesfreedirectory.com