<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
Species:
<form id="form1" name="form1" method="post" action="">
<label>
<select name="species" id="species">
<option>ecoli</option>
<option>yeast</option>
</select>
</label>
</form>
<p>Concentration: </p>
<form id="form2" name="concentration" method="post" action="">
<label>
<input type="text" name="concentration" id="concentration" />
</label>
</form>
<p>Volume: </p>
<form id="form3" name="volume" method="post" action="">
<label>
<input type="text" name="volume" id="volume" />
</label>
</form>
<form id="form4" name="form4" method="post" action="cgi-bin/yield.pl">
<label>
<input type="submit" name="button" id="button" value="Submit" />
</label>
</form>
<p> </p>
</body>
</html>
i had my boss help me out to write a simple script that works in command prompt, it is basically what i want to translate into an html form and a cgi script:
print "\ninput your concentration in ng/ul\n\n";
$concentration = <STDIN>;
print "input your volume in ul\n";
$volume = <STDIN>;
print "your yield is\n";
print ($volume * $concentration);
i do not know how to write the cgi script for this...i've been taking shots in the dark and here is what i've tried (it doesn't work):
#!/usr/local/bin/perl
print "Content-type: text/html \n\n";
$concentration = "concentration";
$volume = "volume";
my $yield = "$concentration * $volume";
print "your yield is $yield";
when i type a sequence in the input box it goes to the correct link of the cgi script but i get "internal server error" and also a 404 not found. the problem lies in the cgi script. my boss said that i should try to figure out how to write function oriented scripts
-RudyS
Your statement makes no sense:
500 Internal Server Error is a problem with the script
404 Not Found - means it never found the script.
(the 404 is probably due to the fact that you have no action specified for your form --- the 500 can be as simple as a missing semi-colon or bracket)..
The two error codes would not be returned for the same issue / problem...
As for your boss telling you to write function oriented scripts, yes -- writing functions is helpful when you need to re-use code, but since you can't get a simple CGI script to run, (and don't seem to understand the underlying principals of CGI), the fact that the script's functionality is coded inline as opposed to being a true "function" (which compares to a "sub-routine" in other programming languages), makes no difference at all.
Did you upload EXAMPLE2.CGI to a webserver and get it to execute? Please give a simple "YES" or "NO" answer... you are straying from the issue.
Your Sequence:
<form id="form1" name="form1" method="post" action="">
<label>
<input type="text" name="$inputlength" id="$inputlength" />
</label>
</form>
<form id="form2" name="form2" method="post" action="cgi-bin/tmcalculator.cgi">
<label>
<input type="submit" name="button" id="button" value="Submit" />
</label>
</form>
I just noticed you are still not even designing your form properly.. Perl_diver showed you by example and explained it many messages ago in this thread.
If you are not going to try to learn from what others share with you here, you might want to just buy a book, (I suggest "The Perl Cookbook" by NAthan Torkington)... you can get it at a library if you don't want to buy it. It will teach you by example... but you need to understand HTML, HTML FORMS, PERL, CGI, FTP, as well as basic programming principals like data modeling and flow.
Your statement makes no sense:500 Internal Server Error is a problem with the script
404 Not Found - means it never found the script.
It is possible to get both. Many servers search for a custom error document to display when a server error occurs, and if none is found it throws the 404 error meaning the custom error document was not found.
I was told that if the perl script can be designed to take all its arguments from the command line, then it is a "simple matter" to run it with a CGI script getting arguments from the submit button on an HTML form? sound reasonable? anyway medranoenrique has it set up that way (like $name = $ARGV[0]; $sequence = $ARGV[1];) and he is spending time with another student to make it work ...
again, sorry for all the bother "I" caused ...
RudyS
never trust user input
the second rule is:
all user input should be treated like poison
the third rule is:
see the first and second rule