Passing two variables in a query string

hello. I was just wondering, I know if I wanted to pass a variable onto another page through a query string, it would be like this:

<a href="newpage.php?name=<?urlencode($_GET['firstname')?> Link </a> 

<BR></DIV><DIV> </DIV><DIV>What would the syntax be if I wanted to pass two variables? (for example firstname and lastname)</DIV><DIV> </DIV><DIV>??perhaps </DIV><DIV> </DIV><DIV>

</DIV><DIV><a href="newpage.php?name=<?urlencode($_GET['firstname and lastname'])?> Link </a> 
 

???

thanks for your help!!

newpage.php?name=[VALUE]&lastname=[VALUE]

make sure to keep in mind, & is a character reference start, so you’ll need to use & to seperate variables in <a href=“”> tags.

<a href="./newpage.php?name=<?php echo urlencode($name); ?>&amp;lastname=<?php echo urlencode($lastname); ?>">Click here</a>

The first parameter’s separator is ?, and anothers are &, HTML ex:
<a href="page.php?name=var1&addr=var2&age=var3>Link </a>

thanks!!

</DIV><DIV> </DIV><DIV>If you want it to validate, you need to replace those &'s with &'s, and make sure you close the quotes :wink: (I think that was a typo).</DIV><DIV> </DIV><DIV>

<a href="page.php?name=var1&amp;addr=var2&amp;age=var3">Link</a>

isn’t that code deprecated with the new php? What is the global variables are set to off?

That still works, you just need to use the $_GET array.
Example:


<a href="./page.php?name=Trav&amp;age=16">Page</a>

Then to get the variables page.php needs to use the $_GET array like so:


<?php
echo $_GET['name'] . '<br />';
echo $_GET['age'];
?>

Travis,

In the past I’ve been using this code to pass variables, for instance to display article 216, page 2 from a mysql database etc. :

i.e. http://mysite.com/article.php/216/2/

<?php

$vars = getenv(“$PATH_INFO”);
$tmp = explode(“/”,$vars);

if(sizeof($tmp) == 2){
$AID = intval($tmp[1]);
$PAGE = intval($tmp[2]);
}

echo (“Aritlce Id : $AID Page : $PAGE”);

?>

Now, with Apache 4.2.x with globals OFF or ON it gives me a 404 message. Apache doesn’t “ignore” the /216/2/ anymore and thinks its an actual directory.

I don’t want to use article.php?aid=216&page=2 or use a form POST in order to be more search engine friendly.

Can you help?

thanks!!

in Apache 2.x, you need to turn on PATH_INFO, i posted info on how to do it before in this forum, try running a search for it.