|
Posted by Tim Streater on 01/09/06 19:27
In article <WpqdnXy8FZIRC1_enZ2dnUVZ_tudnZ2d@scnresearch.com>,
"B Squared" wrote:
> I'm trying to pass a string from the current php page to one I'm
> calling. I've read (in the O'Reilly text) this involves using "?",
> but there's no example. If, for example, given I have a standard
> href in my code
>
> <a href="new_page.php" (string_I_want_to_pass)>
>
> What is the syntax for passing the string? The new page is html
> with some php imbedded, and I'll want to use the string I pass
> inside the php code. So the question is: How to pass a string
> argument in an href call so that it can be used by php?
Try:
<a href="new_page.phtml?phpvar1=string1&phpvar2=string2>Click here</a>
Then inside new_page.phtml you do this:
$wiggy = $_GET["phpvar1"];
$piggy = $_GET["phpvar2"];
and will find that $wiggy contains string1 and $piggy contains string2.
I *think* its $_GET you want. Check on www.php.net/manual/en/ which is
much the best source for PHP docs, in my view. You can pass just one or
a number of args, ? for the first and & for subsequent ones. NB -
string1 etc should have no spaces or other funny chars. Use %20 for a
space, or use urlencode on your strings before passing them.
-- tim
Navigation:
[Reply to this message]
|