PDA

View Full Version : Parse URL parameters into simple HTML?



jlizarraga
09-01-2008, 02:06 AM
Hi all.

I know very little PHP, but what I want to do is very basic. Looking at the URL of this Post New Thread page, it ends with "?do=newthread&f=11". I want to output these types of parameters like so:


<input type="hidden" name="do" value="newthread" />
<input type="hidden" name="f" value="11" />

Is this possible/easy?

Thanks for any responses!

techietim
09-01-2008, 02:11 AM
These are called $_GET parameters. If you want to list only specific one's, you'd use this:


echo '<input type="hidden" name="do" value="' . $_GET['do'] . '" />';
echo '<input type="hidden" name="f" value="' . $_GET['f'] . '" />';

If you want it to loop through all the $_GET parameters, you'd use this:


foreach($_GET as $key => $value)
echo '<input type="hidden" name="' . $key . '" value="' . $value . '" />';

jlizarraga
09-01-2008, 02:54 AM
Thank you!

Twey
09-01-2008, 04:27 AM
But beware: http://dynamicdrive.com/forums/showpost.php?p=158839&postcount=1337 — 1.3, 4.1.

jlizarraga
09-01-2008, 04:47 AM
Okay, I'm trying to take this all in. @_@

For 1.3: What does this mean exactly, that it is bad to use PHP in conjunction with "error-corrected into validity" XHTML? My page is all valid XHTML 1.0 strict (and from what I understand from the links is being displayed as HTML by browsers). When I view source on this page, I see XHTML. Does the forum take extra steps to be compatible?

4.1 shouldn't be a problem, this is all temporary.

Thanks.

Twey
09-01-2008, 08:06 AM
I suggest reading the associated link(s). Please don't use DD to judge code quality :)