Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing arguments to perl script via a web form

Status
Not open for further replies.

milkchug89

Programmer
Oct 13, 2003
1
US
I am trying to pass arguments to a cgi script via a web form. The first time your go to the cgi script the script checks to see if you sent it any arguments, if not it starts off with a default login page. You then send the login information back to the script and then it will do some other stuff. The problem I am having is that when I send the login infomation to the script it still thinks there are no arguments. I'm not sure if I'm not checking for parameters right or not sending the form info right
here is the code.
Code:
#!/soft/perl5.8/bin/perl -w



#use strict;
use Fcntl qw/:flock/; 
#use warnings;
#use CGI ':standard';
use CGI::Carp;
use File::stat;
use IO::Socket::INET qw(:DEFAULT :crlf);
#use CGI qw(:standard );
use CGI qw(:standard :html3 :netscape -debug);
$q=new CGI;


if(!param()){
	print $q->header;
	print $q->start_html();
	print "the butt of it is ";
	print param('control');
	print &quot;<br>&quot;;
	print qq(
		<form METHOD=&quot;POST&quot; ACTION=&quot;[URL unfurl="true"]http://www.itlabs.umn.edu/~hast0044/IMAPClient.cgi&quot;>[/URL]

		<h1> Please login to the IMAP Server
		<br>
		<h3>
		<input TYPE=TEXT NAME=&quot;Login-name&quot;  VALUE=&quot;&quot; >
		<br><br>
		UMN Login Name (X.500)
		<br>
		<br>
      
		<input TYPE=PASSWORD NAME=&quot;Password&quot;  VALUE=&quot;&quot; >
		<br><br>
		Password
		<br>
		<br>
		<input TYPE=HIDDEN NAME=&quot;control&quot; VALUE=&quot;login&quot;>
		<input TYPE=SUBMIT NAME=&quot;SubmitButton&quot; VALUE=&quot;SUBMIT&quot;>
		<tr>
		<input TYPE=RESET NAME=&quot;ResetButton&quot; VALUE=&quot;CLEAR&quot;>

		</form>
	);
print $q->end_html;
}

elsif(param('control') eq &quot;login&quot;){
	print $q->header;
	print $q->start_html();
	print qq(
			Connected to IMAP Server<br><br>Existing Messages:
			163<br><br>Recent Messages: 0<br><br><br><hr>
			<form name=&quot;form2&quot; method=&quot;post&quot; action=&quot;&quot;>
			<div align=&quot;center&quot;><p><font size=&quot;4&quot;>
			Range of Email numbers</font>
			<input type=&quot;text&quot; name=&quot;range&quot; size=&quot;70&quot;>
			<input type=&quot;submit&quot; name=&quot;Submit&quot; value=&quot;Range &quot;>
			</div>
			<br><br><div align=&quot;center&quot;><p><font size=&quot;4&quot;>
			LOGOUT</font>
			<input type=&quot;submit&quot; name=&quot;LOGOUT&quot; value=&quot;LOGOUT &quot;>
			</div>
			</form>
	);
print $q->end_html;

}
 
Instead of using param()

try

$q->param()

Param() is defined in CGI.pm but without an object on the calling method it will always eval to false.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top