We want to be able to send a URL to folks to fill out a survey. But we want the link to contain a code that will get dumped into a hidden field on the form. The people doing it want to use specific groups, so they will just change the group code in the URL and that info will get passed to the generic form and they will be able to sort later.
we will send an email to some prospective beta testors for some hardware. We are sending them in groups. group a, group b, group c etc. Instead of doing multiple html forms with the group info encoded in them, i wanted to pass the info from the link. so it would be something like this http://www.linkhere.com then whatever is needed to add "groupa" to the form. So that when they submit the form, "groupa" will be transmitted with it.
The only way I know of to do it (and there are probably others, this is just the only way that *I* know of to do it), would be to have the link they click bring up a web application (I'd be using Perl) that would parse out the URL so that anything after the question mark was assigned to a variable. The app would then display the form, putting the value of the variable in the form as a hidden field (or not hidden, whatever your preference).
In PHP, read the value of $_GET['group'] and write it out as a in the HTML that the PHP code generates.
That should achieve exactly what you want.
Edit:
Alright. Here is the PHP code. Just change your regular from's filename from .html to .php.
You could also do this as a one-liner, but it is a bit harder to read and more prone to typos.
\n"; ?>
This technique scales well to a high number of groups.
If you only have three or four groups and don't know PHP (or Perl or whatever), just use three or four different URLs to different HTML forms. Each form has the hidden variable coded directly in it. Send the appropriate URL to the appropriate group.
[quote TheTominator]
If you only have three or four groups and don't know PHP (or Perl or whatever), just use three or four different URLs to different HTML forms. Each form has the hidden variable coded directly in it. Send the appropriate URL to the appropriate group.
thats exactly what i was going to do. I'm not sure how many groups there would be. If there are a lot, i will go the PHP route. if not, i will just use a couple different forms.
The really sweet thing about PHP is that you can use the rest of your HTML page as is. In this case, at minimum, you really only need to add one line to the file and change the filename to end in .php instead of .html.
This assumes that your web server is configured to interpret PHP files already. If not, then you need to turn on that capability.