tags:

views:

27

answers:

3

This may be a really stupid and easy question, so I apolgoize in advance.

How can you make a form be able to fill a field with the url?

Example: if i have two fields, username and password, and my form is located at form.html how can I make form.html?username=example automatically fill in "example" in the username field.

Thanks.

A: 

The webserver language (e.g. PHP) must access the variables (e.g. $_GET["username"]) and supply them as values to the HTML fields. Don't forget to use method="get" in the HTML.

mcandre
A: 

If your url is form.html, then how are you going to end up with form.html?username=example?

?username=example is a query string. If your submitting your form with a GET method, it will use a query string and append it to your url so the way you'd get form.html?username=example would be if a user entered their username as "example" and then submitted the form.

Catfish
+2  A: 

OK, so the user puts this URL into his browser, a request is made to the server, and the page comes back to the user. There are two general approaches you can use to filling in the form details. 1. You can make it happen on the server. 2. You can make it happen on the client. If you want to make it happen on the server then you're going to need to use a server-side technology like ASP.NET, PHP, JSP, etc. If you want to make it happen on the client then you'll need a client-side technology that will almost certainly be javascript.

There's a whole lot more to say about this, including warnings about security holes like cross-site scripting, but I'll leave those for now.

Yellowfog