Re: CGI with hyperlink
- Posted by dukester Dec 26, 2010
- 1586 views
[snip]
Can I setup another form that uses the hyperlinks somehow as the post criteria? Or is there another method?
You bet!
When you use the GET method, data is sent via the QUERY_STRING environment variable. When you use the POST method, the data is sent vis STDIN. Either way, the data is "packaged" the same way, i.e. it has to be encoded. For example the QUERY_STRING might contain:
star=Eastwood&cert=15&movie=Pale+Rider
each variable=value pair is separated by a "&"
spaces are replaced with a "+"
certain characters are replaced with their hex values like %xx
So, to send send the data via a link on your webpage, encode it (as shown above) and append it to your URL, like:
<a href="http://www.hotchef.com/cgi-bin/my-script.cgi?star=Eastwood&cert=15&movie=Pale+Rider">Chef's Movie of the week</a>
Actually, the above link is the very same data that would be sent to the server (and that would appear in your browser's navigation window) using a web form.
HTH ...
Duke