Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
passing form info through a link
#1
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.
Reply
#2
Why does this sound wrong to me? More details please. I don't want a "hidden field" in anything I respond to...
Reply
#3
sounds like you need to learn about POST and GET forms.
Reply
#4
ok...it doesn't have to be hidden.

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.
Reply
#5
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).

The URL would look like this:

http:/ /www.myserver.com/cgi-bin/my_web_app.cgi?value_number_one


"value_number_one" would then be assigned to a variable, and you could put it in the form however you liked.
Reply
#6
Yeah. What The UnDoug said.

I would format the url something like:

http:/ /www.myserver.com/myform.php?group=a

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.





$groupValue = $_GET['group']
echo <<
HIDDENGROUPLINE;
?>



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.
Reply
#7
I am not trying to make your end task sound evil.

I am sure this happens all of the time on the internet, but your description still sounds sinister to me.

JJ
Reply
#8
[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.

I just wanted to see if there was an alternative.
Reply
#9
[quote mattkime]sounds like you need to learn about POST and GET forms.
If thats what i wanted to do, i wouldn't have asked here.
Reply
#10
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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)