Click to See Complete Forum and Search --> : Tricky Form


The Nooby
09-14-2005, 10:23 PM
HELP Please. Alright im pretty new to HTML but i managed to throw together this site: www.br-pro.com

anyway i have a question on a form i am working on. Here the deal i have a text feild and a submit button. When somebody types something in the text feild and presses the submit button i want it to automaticly put Watever the person typed in the text feild on the end of this Url and then have it go to the URL with watever they typed on the end. Heres the URL:

http://www.h2advanced.com/stats/search.php?=

So i got it pretty much working i think. heres the Html i wrote for it:

<html>
<body>

<form name="input" action="http://www.h2advanced.com/stats/user.php?u=" method="get">

Type your Gamertag Here:
<input type="text" name="FirstName" value="???Gamertag???" size="20">

<input type="submit" value="Submit">

</form>

<p>
If you click the "Get Stats", you will be automaticly redirected to your player stats.
</p>

</body>
</html>

Ok now thats the Html. So heres my problem. This inputs watever they type in the text feild on the end of the url and goes to it but theres a problem. here is what the url should look like when a person has gone to it. (example of me typing in: Maven 01: in the text feild)

http://www.h2advanced.com/stats/user.php?u=Maven 01

but instead it looks like this:

http://www.h2advanced.com/stats/user.php?FirstName=Maven+01

as you can see it automaticly adds: FirstName: on the url for some reason and erases the U at the end of the url after PHP?:

Can anybody help me so that the final URL it goes to after typing in watever is:

http://www.h2advanced.com/stats/user.php?u=

then have it so watever they type goes on the end of the = sign.
thank you,
Nick

Kravvitz
09-14-2005, 11:36 PM
Please use bbcode code tags when you post code.

That's the way it's supposed to work.

<form name="input" action="http://www.h2advanced.com/stats/user.php" method="get">

Type your Gamertag Here:
<input type="text" name="FirstName" value="???Gamertag???" size="20">
<input type="hidden" name="u" value="Maven">
<input type="submit" value="Submit">

</form>

The Nooby
09-14-2005, 11:52 PM
Nope thats not it. I didn't mean put maven 01 on the end of the url.

i want watever the person types in the text feild to be put on the end of the url.

thanks anyway

Kravvitz
09-15-2005, 12:02 AM
*sigh* I suppose I should explain.

When you use the get method it overwrites any query string in the URL of the form's action. Thus you need to use an <input type="hidden">.

If you use the post method, then the query string in the URL of the form's action will not be overwritten.

The Nooby
09-15-2005, 12:11 AM
like i said im kinda a noob at this. wanna right the html for the post thing you where just talkin about really quik? please

Kravvitz
09-15-2005, 12:14 AM
All you have to do is change the method attribute's value to "post".
I should make it clear that this will not add the text entered in the form to the end of the URL.

<form name="input" action="http://www.h2advanced.com/stats/user.php?u=" method="post">

Type your Gamertag Here:
<input type="text" name="FirstName" value="???Gamertag???" size="20">

<input type="submit" value="Submit">

</form>

The Nooby
09-15-2005, 01:31 AM
ok does anybody have the html for what i want. cause what is shown above is pointless. it doesn't do anything but when you press the submit button it goes to a url.

thanks

the tree
09-15-2005, 02:22 AM
ok does anybody have the html for what i want. cause what is shown above is pointless. it doesn't do anything but when you press the submit button it goes to a url. Yes it does, it sends the variable in the POST header, just like the form you type your replies in here.
Since you insist...<form id="input" action="/stats/user.php" method="GET">
<label for="FirstName">Type your GamerTag here</label>
<input type="text" name="FirstName" value="Gamertag">
<input type="hidden" name="u" value="">
<input type="submit" value="Get Stats">
</form>