GorGor1
asked on
perl+forms...i screwed it up
I screwed up this script somehow...I was hoping someone could help me debug this. After the form is submitted the first time, I get a blank page. Nothing shows up on page 2. If you want to see the script in action, go to www.wwwebsolutions.net/cgi-bin/order.pl
Here's the script:
========================== ========== ==
#!/usr/bin/perl
use CGI;
$q=new CGI;
## Send the proper MIME header to the browser.
print "Content-type: text/html\n\n";
if ($q->param){
## Read the HTML Form variables into local PERL variables.
## NOTE: the variable names are case sensitive. so fn is NOT the same as FN or Fn or fN.
$page=$q->param('page');
$name=$q->param('name');
$title=$q->param('title');
$company=$q->param('compan y');
$address=$q->param('addres s');
$city=$q->param('city');
$state=$q->param('state');
$zip=$q->param('zip');
$phone=$q->param('phone');
$fax=$q->param('fax');
$email=$q->param('email');
$order1=$q->param('order1' );
$order2=$q->param('order2' );
$order3=$q->param('order3' );
$order4=$q->param('order4' );
$order5=$q->param('order5' );
$order6=$q->param('order6' );
$quantity1=$q->param('quan tity1');
$quantity2=$q->param('quan tity2');
$quantity3=$q->param('quan tity3');
$quantity4=$q->param('quan tity4');
$quantity5=$q->param('quan tity5');
$quantity6=$q->param('quan tity6');
## Find out which button the user clicked!!
$action=$q->param('action' );
if ($page=~ /^1$/){
#print "<B> Are you sure all the info is correct?</B><P>\n";
$page++;
}elsif ($page=~ /^2$/){
if ($action=~ /^Finish$/){ ## Finish button was clicked
print "OK!! All your info has been accepted!!<P>\n";
## The send out as email part of the code will go here.
# ## Print the users info!!
# print "Name is <B>$name</B><br>\n";
# print "Company is <B>$company</B><br>\n";
exit;
}
}
}else{
$page=1 if (!$page);
}
if ($page=~ /^1$/){ ## Print the First page i.e. HTML form.
print qq{
<html>
<body bgcolor="white">
<form method=post action="$ENV{'SCRIPT_NAME' }">
<table cellpadding=0 cellspacing=0>
<tr valign="top">
<td>
NAME<br>
<input type=text size=40 name=name>
</td>
<td>
TITLE<br>
<input type=text size=30 name=title>
</td>
</tr>
</table>
COMPANY<br>
<input type=text size=70 name=company><br>
ADDRESS<br>
<input type=text size=70 name=address><br>
<table cellspacing=0 cellpadding=0>
<tr valign="top">
<td>
CITY<br>
<input type=text size=30 name=city>
</td>
<td>
STATE<br>
<input type=text size=10 name=state>
</td>
<td>
ZIP<br>
<input type=text size=10 name=zip>
</td>
</tr>
</table>
<table cellspacing=0 cellpadding=0>
<tr valign="top">
<td>
PHONE<br>
<input type=text size=35 name=phone>
</td>
<td>
FAX<br>
<input type=text size=35 name=fax>
</td>
</tr>
</table>
E-MAIL<br>
<input type=text size=70 name=email><br>
<table cellspacing=0 cellpadding=0>
<tr valign="top">
<td>
ORDER #<br>
<input type=text size=10 name=order1 value=$order1><br>
<input type=text size=10 name=order2><br>
<input type=text size=10 name=order3><br>
<input type=text size=10 name=order4><br>
<input type=text size=10 name=order5><br>
<input type=text size=10 name=order6><br>
<input type=hidden name=page>
</td>
<td>
QUANTITY:<br>
<input type=text size=7 name=quantity1><br>
<input type=text size=7 name=quantity2><br>
<input type=text size=7 name=quantity3><br>
<input type=text size=7 name=quantity4><br>
<input type=text size=7 name=quantity5><br>
<input type=text size=7 name=quantity6><br>
</td>
</tr>
</table>
<br>
<input type=submit name=action value="Submit">
</b>
</form>
</body>
</html>
};
}elsif ($page=~ /^2$/){ ## Show the user the info entered & seek confirmation.
print qq{
<body bgcolor="white">
<font size=2 color="red">
<b>Your Name: </b>$name<br>
<b>Your Title: </b>$title<br>
<b>Company: </b>$company<br>
<b>Address:</b>$address<br >
<b>City: </b>$city<br>
<b>State: </b>$state<br>
<b>Zip: </b>$zip<br>
<b>Phone #: </b>$phone<br>
<b>Fax #: </b>$fax<br>
<b>E-Mail Address: </b>$email<br>
<b>Order #1: </b>$order1<br>
<b>Order #2: </b>$order2<br>
<b>Order #3: </b>$order3<br>
<b>Order #4: </b>$order4<br>
<b>Order #5: </b>$order5<br>
<b>Order #6: </b>$order6<br>
<b>Quantity #1: </b>$quantity1<br>
<b>Quantity #2: </b>$quantity2<br>
<b>Quantity #3: </b>$quantity3<br>
<b>Quantity #4: </b>$quantity4<br>
<b>Quantity #5: </b>$quantity5<br>
<b>Quantity #6: </b>$quantity6<br>
Is this information correct?<br>
If it is, then click the "Finish" button to e-mail your order.<br>
If it is not correct, click the "Back" button on your browser to change any fields.<br>
<br>
<center>
<FORM METHOD=POST ACTION="$ENV{'SCRIPT_NAME' }">
<input type=hidden name=page value=$page>
<input type=submit name=action value="Finish">
</FORM>
</font>
</center>
</body>
};
}
========================== ========
Thanks
Here's the script:
==========================
#!/usr/bin/perl
use CGI;
$q=new CGI;
## Send the proper MIME header to the browser.
print "Content-type: text/html\n\n";
if ($q->param){
## Read the HTML Form variables into local PERL variables.
## NOTE: the variable names are case sensitive. so fn is NOT the same as FN or Fn or fN.
$page=$q->param('page');
$name=$q->param('name');
$title=$q->param('title');
$company=$q->param('compan
$address=$q->param('addres
$city=$q->param('city');
$state=$q->param('state');
$zip=$q->param('zip');
$phone=$q->param('phone');
$fax=$q->param('fax');
$email=$q->param('email');
$order1=$q->param('order1'
$order2=$q->param('order2'
$order3=$q->param('order3'
$order4=$q->param('order4'
$order5=$q->param('order5'
$order6=$q->param('order6'
$quantity1=$q->param('quan
$quantity2=$q->param('quan
$quantity3=$q->param('quan
$quantity4=$q->param('quan
$quantity5=$q->param('quan
$quantity6=$q->param('quan
## Find out which button the user clicked!!
$action=$q->param('action'
if ($page=~ /^1$/){
#print "<B> Are you sure all the info is correct?</B><P>\n";
$page++;
}elsif ($page=~ /^2$/){
if ($action=~ /^Finish$/){ ## Finish button was clicked
print "OK!! All your info has been accepted!!<P>\n";
## The send out as email part of the code will go here.
# ## Print the users info!!
# print "Name is <B>$name</B><br>\n";
# print "Company is <B>$company</B><br>\n";
exit;
}
}
}else{
$page=1 if (!$page);
}
if ($page=~ /^1$/){ ## Print the First page i.e. HTML form.
print qq{
<html>
<body bgcolor="white">
<form method=post action="$ENV{'SCRIPT_NAME'
<table cellpadding=0 cellspacing=0>
<tr valign="top">
<td>
NAME<br>
<input type=text size=40 name=name>
</td>
<td>
TITLE<br>
<input type=text size=30 name=title>
</td>
</tr>
</table>
COMPANY<br>
<input type=text size=70 name=company><br>
ADDRESS<br>
<input type=text size=70 name=address><br>
<table cellspacing=0 cellpadding=0>
<tr valign="top">
<td>
CITY<br>
<input type=text size=30 name=city>
</td>
<td>
STATE<br>
<input type=text size=10 name=state>
</td>
<td>
ZIP<br>
<input type=text size=10 name=zip>
</td>
</tr>
</table>
<table cellspacing=0 cellpadding=0>
<tr valign="top">
<td>
PHONE<br>
<input type=text size=35 name=phone>
</td>
<td>
FAX<br>
<input type=text size=35 name=fax>
</td>
</tr>
</table>
E-MAIL<br>
<input type=text size=70 name=email><br>
<table cellspacing=0 cellpadding=0>
<tr valign="top">
<td>
ORDER #<br>
<input type=text size=10 name=order1 value=$order1><br>
<input type=text size=10 name=order2><br>
<input type=text size=10 name=order3><br>
<input type=text size=10 name=order4><br>
<input type=text size=10 name=order5><br>
<input type=text size=10 name=order6><br>
<input type=hidden name=page>
</td>
<td>
QUANTITY:<br>
<input type=text size=7 name=quantity1><br>
<input type=text size=7 name=quantity2><br>
<input type=text size=7 name=quantity3><br>
<input type=text size=7 name=quantity4><br>
<input type=text size=7 name=quantity5><br>
<input type=text size=7 name=quantity6><br>
</td>
</tr>
</table>
<br>
<input type=submit name=action value="Submit">
</b>
</form>
</body>
</html>
};
}elsif ($page=~ /^2$/){ ## Show the user the info entered & seek confirmation.
print qq{
<body bgcolor="white">
<font size=2 color="red">
<b>Your Name: </b>$name<br>
<b>Your Title: </b>$title<br>
<b>Company: </b>$company<br>
<b>Address:</b>$address<br
<b>City: </b>$city<br>
<b>State: </b>$state<br>
<b>Zip: </b>$zip<br>
<b>Phone #: </b>$phone<br>
<b>Fax #: </b>$fax<br>
<b>E-Mail Address: </b>$email<br>
<b>Order #1: </b>$order1<br>
<b>Order #2: </b>$order2<br>
<b>Order #3: </b>$order3<br>
<b>Order #4: </b>$order4<br>
<b>Order #5: </b>$order5<br>
<b>Order #6: </b>$order6<br>
<b>Quantity #1: </b>$quantity1<br>
<b>Quantity #2: </b>$quantity2<br>
<b>Quantity #3: </b>$quantity3<br>
<b>Quantity #4: </b>$quantity4<br>
<b>Quantity #5: </b>$quantity5<br>
<b>Quantity #6: </b>$quantity6<br>
Is this information correct?<br>
If it is, then click the "Finish" button to e-mail your order.<br>
If it is not correct, click the "Back" button on your browser to change any fields.<br>
<br>
<center>
<FORM METHOD=POST ACTION="$ENV{'SCRIPT_NAME'
<input type=hidden name=page value=$page>
<input type=submit name=action value="Finish">
</FORM>
</font>
</center>
</body>
};
}
==========================
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER