homepage Welcome to WebmasterWorld Guest from 54.167.144.202
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / WebmasterWorld / Webmaster General
Forum Library, Charter, Moderators: phranque

Webmaster General Forum

    
How to make URL reflect form input
kodaks

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 10190 posted 11:43 pm on Nov 2, 2005 (gmt 0)

Hello everyone!

I would like to know if there is a way to make whatever the URL used to get to a page is, reflect on the input of a form on that page. I know most of you are going "huh?" right now, so allow me to explain.

A user goes to a URL like:
http://www.example.com/member.php?name=John

On the member.php page, there is a form and one of the inputs is "name".

So when the page loads, "John" will already be in one of the form's fields.

I hope this is not too confusing, and thanks in advance for any assistance.

 

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 10190 posted 11:54 pm on Nov 2, 2005 (gmt 0)

You output the form dynamically, with appropriate variables in the value fields. If the form is called without a query string, they will be blank (as the values are null.)

A perl-ey example:

http://www.example.com/member.cgi?name=John

%qs = &query; ## Read/parse, associates $qs{'name'} = 'John';

print "content-type: text/html\n\n";

print <<"EOFORM";
<html><head><title>Hello $qs{'name'}</title></head></html>

<body>
<h3>Hello $qs{'name'}</h3>

<form>
<input type="text" name="name" value="$qs{'name'}">
</form>
</body>
</html>

EOFORM

You can do this using the language of your choice, or if on a static page, with Javascript or VBScript. The methods will differ, but the concept is the same, parse a query string/form post and use the variables to populate the form.

kodaks

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 10190 posted 11:57 pm on Nov 2, 2005 (gmt 0)

Thank you very much for your reply!

Is there any way I can do this with php or html?

kodaks

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 10190 posted 1:13 am on Nov 3, 2005 (gmt 0)

Added:
It seems that Vbulletin uses this kind of script to when you try to register. It asks you what your birthday is and then the next page displays as:
[forumname.com...] month=6&year=1984&day=2

Anybody know how else to do this? Thanks!

Dijkgraaf

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 10190 posted 1:22 am on Nov 3, 2005 (gmt 0)

Yes you can do it with PHP, no for just HTML as that is just a markup language, you need to use something in addition to HTML such as JavaScript, PHP, Perl, ASP etc. to fill in the field.
With your example of
?month=6&year=1984&day=2
then with PHP you would have
<input name="month" value="<? echo $month?>">

kodaks

WebmasterWorld Senior Member 10+ Year Member



 
Msg#: 10190 posted 1:31 am on Nov 3, 2005 (gmt 0)

Thanks, will try!

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 10190 posted 5:44 pm on Nov 3, 2005 (gmt 0)

as I mentioned, you can do it in a static HTML page BUT you must use Javascript, VBscript, or some other client-side language.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / Webmaster General
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved