Long story short, I'm making a website, and on my site, I have 2 pictures, and you can vote which one is better, the left one or right one. Here is that part of the code...


Code:

<form method=post action="/cgi-bin/example.cgi">
Which picture is better?:<br>
<input type="radio" name="option"> Left Pic
<input type="radio" name="option" checked> Right Pic
<input type="Submit" value="Submit">
</form>


My questions are;
--When the user clicks submit, what does the website do with the option that is picked, does it store it somewhere?
---Can I make a live ticker or counter that goes next to each picture that shows how many times each picture was voted for?

Thanks so much in advance, Smile
Sounds like you need PHP, and possibly a .txt file to store the stats into.
Well, when I test out the submit button, it says;

"No webpage was found for the web address: file:///C:/cgi-bin/example.cgi"

What exactly is a .cgi file, and If someone on a different computer hits the submit button, it's not like it would go to the cgi file on my computer.. would it?
No, it's trying to go to your computer. You need a server host that supports .cgi files.
You need a CGI or a PHP script to handle form input like that. Depending on the ACTION attribute of your [form] tag, the data is either passed to the script in GET or POST. To run a CGI script on your computer, you need to install a web server such as Apache.
You could also try to find someone's server to put that script on. And, it would probably be best to install Apache on your computer to do testing of CGI (Common Gateway Interface, google it Smile) scripts. PHP is one of the main languages for server-side programming, but you can use any language (Python, Bash, Lisp, whatever you want). Your script will send things through POST, which means that the data just gets sent to the server, and you don't see it in the URL. For instance, this thread has values after the ?, these are variables sent to the server, but they are sent via GET. In PHP, you could get the POST variable "option" by doing:
Code:
<?php
  echo $_POST["option"]
?>
PHP would indeed be your best option for storing the results of a page like this. The simplest PHP script could simply store a delimited line for each form submission into a flatfile.
Nonono, you must install Apache Tomcat, learn Servlets and JSPs, redesign every page in your site with JSPs, and implement Jakarta Struts for your form age.
Of course, you should disregard that.
Indeed, you should use Python and run on Google App Engine instead.
Sigh. Let's get back to the part where we help him to actually cobble this together, please thanks byte.
KermMartian wrote:
Sigh. Let's get back to the part where we help him to actually cobble this together, please thanks byte.


Heh.

Actually, more seriously, Google App Engine might be a good option. It's free, it has a very easy to setup local server, integrates nicely with Eclipse, and you can use Python, Java, or Go. Much simpler and, well, better than your typical LAMP stack.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement