PDA

View Full Version : Help debugging this plz


bazz
08-12-2004, 04:08 PM
Plz tell me why IE is showing an error in the status bar for this scirpt. I can't see what is wrong.

#!/usr/bin/perl

use CGI qw(:standard :form);
use strict;

# The Email Address will be used to receive mail
my $recipient = 'enquiries@ireland-info.com';


# The Subject Title of the mail
my $subject = 'Internet enquiry via ireland-info.com';

# Path to sendmail (defualt /usr/sbin/sendmail)
my $mail_prog = '/usr/sbin/sendmail';

# Fields of the HTML form.
my @fields = ('checkInDay','checkInMonthYear','checkOutDay','checkOutMonthYear','surname','firstname','address1', 'address2','address3','zip','telephone','email','fax','numberOfSingleRooms','numberOfTwinRoomsS_occ' ,'numberOfTwinRoomsF_occ','numberOfDoubleRoomsS_occ','numberOfDoubleRoomsD_occ','AdditionalRequireme nts');


my $dpt_dat_file = './dpt.dat';

my $query = new CGI;
my $script_url = $ENV{'SCRIPT_NAME'};
my $department = $query->param('dpt');
my $section = $query->param('section');
my $action = $query->param('action');
my ($dpt,$dpt_html,$dpt_img,$dpt_name,$dpt_email,$dpt_imagemain,$dpt_thumb1,$dpt_thumb2,$dpt_thumb3,$dp t_address,$dpt_url,$dpt_hyperlink1,$dpt_hyperlink2,$dpt_hyperlink3,$dpt_image1,$dpt_image2,$dpt_imag e3,$dpt_imagelarge,$dpt_enquiries,$dpt_reservations,$dpt_intro,$dpt_facilities,$dpt_findus,$dpt_attr actions,$dpt_dining,$dpt_taxi,$dpt_taxiurl,$dpt_tellafriend,$dpt_ipix,$dpt_text);

print $query->header(-type=>'text/html');

$section = 'txt' if(!$section);

open(DPTDAT,"<$dpt_dat_file");
while(<DPTDAT>) {
chomp;
if($_ =~ /^$department\t/) {
($dpt,$dpt_html,$dpt_img,$dpt_name,$dpt_email,$dpt_imagemain,$dpt_thumb1,$dpt_thumb2,$dpt_thumb3,$dp t_address,$dpt_url,$dpt_hyperlink1,$dpt_hyperlink2,$dpt_hyperlink3,$dpt_image1,$dpt_image2,$dpt_imag e3,$dpt_imagelarge,$dpt_enquiries,$dpt_reservations,$dpt_intro,$dpt_facilities,$dpt_findus,$dpt_attr actions,$dpt_dining,$dpt_taxi,$dpt_taxiurl,$dpt_tellafriend,$dpt_ipix,$dpt_text) = split(/\t/,$_);

}
}
close(DPTDAT);

if($action eq 'result') { &result; }
else { &form; }



sub form {
print qq(

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>$dpt_name</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="http://www.ireland-info.com/style_perlflypage_validated_new.css" type="text/css">
<link rel="stylesheet" href="http://www.ireland-info.com/style_perlreservations_new.css" type="text/css">

</head>

<body>

<SCRIPT LANGUAGE="JavaScript">

function checkFields() {
var form = document.forms.myForm;
if (form.realname.value && form.email.value && form.body.value) {
form.submit();
}else {
alert("Please fill in all fields of the form");
}
}
</script>


<!-- START OF FORM DETAILS-->
<FORM name="myForm" METHOD="POST" ACTION="$script_url">
<INPUT TYPE="HIDDEN" NAME="action" VALUE="result">
<INPUT TYPE="HIDDEN" NAME="dpt" VALUE="$department">

<div class="header">
<a href="$dpt_url"><img class="premiseslogo" src="$dpt_img" alt=""></a>

<a href="$dpt_hyperlink1" onFocus="if(this.blur)this.blur()"><img class="th1" src="$dpt_thumb1" alt="$dpt_name View 1" /></a>
<a href="$dpt_hyperlink2" onFocus="if(this.blur)this.blur()"><img class="th2" src="$dpt_thumb2" alt="$dpt_name View 2" /></a>
<a href="$dpt_hyperlink3" onFocus="if(this.blur)this.blur()"><img class="th3" src="$dpt_thumb3" alt="$dpt_name View 3" /></a>
</div>







<div class="textmenubkgrnd"><a class="textmenu" href="$dpt_enquiries">&nbsp;Contact $dpt_name&nbsp;</a>&nbsp;<a class="textmenu" href="$dpt_reservations">&nbsp;Bookings&nbsp;</a>&nbsp;<a class="textmenu" href="$dpt_intro">&nbsp;Introduction&nbsp;</a>&nbsp;<a class="textmenu" href="$dpt_findus">&nbsp;Find Us&nbsp;</a>&nbsp;<a class="textmenu" href="$dpt_tellafriend">&nbsp;Tell A friend&nbsp;</a>&nbsp;<a class="textmenu" href="http://www.ireland-info.com/sitemap.htm">&nbsp;Sitemap&nbsp;</a>&nbsp;<a class="textmenu" href="http://www.ireland-info.com">&nbsp;Home Page&nbsp;</a></div>



<div class="reservationsleftdiv">
<strong>Date Of Arrival:&nbsp;</strong>&nbsp; &nbsp; &nbsp;<SELECT class="textbox"
name="checkInDay">
<OPTION value=1>1</OPTION>
<OPTION value=2>2</OPTION> <OPTION value=3>3</OPTION>
<OPTION value=4>4</OPTION>
<OPTION value=5>5</OPTION>
<OPTION value=6>6</OPTION>
<OPTION value=7>7</OPTION>
<OPTION value=8>8</OPTION>
<OPTION value=9>9</OPTION>
<OPTION value=10>10</OPTION>
<OPTION value=11>11</OPTION>
<OPTION value=12>12</OPTION>
<OPTION value=13>13</OPTION>
<OPTION value=14>14</OPTION>
<OPTION value=15>15</OPTION>
<OPTION value=16>16</OPTION>
<OPTION value=17>17</OPTION>
<OPTION value=18>18</OPTION>
<OPTION value=19>19</OPTION>
<OPTION value=20>20</OPTION>
<OPTION value=21>21</OPTION>
<OPTION value=22>22</OPTION>
<OPTION value=23>23</OPTION>
<OPTION value=24 selected>24</OPTION>
<OPTION value=25>25</OPTION> <OPTION value=26>26</OPTION>
<OPTION value=27>27</OPTION>
<OPTION value=28>28</OPTION> <OPTION value=29>29</OPTION> <OPTION value=30>30</OPTION> <OPTION value=31>31</OPTION> </SELECT>&nbsp; <SELECT class="textbox">
<OPTION value="April 2004" selected>Apr 2004</OPTION>
<OPTION value="May 2004">May 2004</OPTION>
<OPTION value="June 2004">Jun 2004</OPTION>
<OPTION value="July 2004">Jul 2004</OPTION>
<OPTION value="August 2004">Aug 2004</OPTION>
<OPTION value="September 2004">Sep 2004</OPTION>
<OPTION value="October 2004">Oct 2004</OPTION>
<OPTION value="November 2004">Nov 2004</OPTION>
<OPTION value="December 2004">Dec 2004</OPTION>
<OPTION value="January 2005">Jan 2005</OPTION>
<OPTION value="February 2005">Feb 2005</OPTION>
<OPTION value="March 2005">Mar 2005</OPTION>
<OPTION value="April 2005">Apr 2005</OPTION>
<OPTION value="May 2005">May 2005</OPTION>
<OPTION value="June 2005">Jun 2005</OPTION>
<OPTION value="July 2005">Jul 2005</OPTION>
<OPTION value="August 2005">Aug 2005</OPTION>
<OPTION value="September 2005">Sep 2005</OPTION>
<OPTION value="October 2005">Oct 2005</OPTION>
<OPTION value="November 2005">Nov 2005</OPTION>
<OPTION value="December 2005">Dec 2005</OPTION>
<OPTION value="January 2006">Jan 2006</OPTION>
<OPTION value="February 2006">Feb 2006</OPTION>
<OPTION value="March 2006">Mar 2006</OPTION>
<OPTION value="April 2006">Apr 2006</OPTION>
</SELECT><br />
<strong>Date of Departure: &nbsp;</strong>&nbsp; &nbsp; &nbsp;<SELECT class="textbox"
name="checkOutDay">
<OPTION value=1>1</OPTION>
<OPTION value=2>2</OPTION> <OPTION value=3>3</OPTION>
<OPTION value=4>4</OPTION>
<OPTION value=5>5</OPTION>
<OPTION value=6>6</OPTION>
<OPTION value=7>7</OPTION>
<OPTION value=8>8</OPTION>
<OPTION value=9>9</OPTION>
<OPTION value=10>10</OPTION>
<OPTION value=11>11</OPTION>
<OPTION value=12>12</OPTION>
<OPTION value=13>13</OPTION>
<OPTION value=14>14</OPTION>
<OPTION value=15>15</OPTION>
<OPTION value=16>16</OPTION>
<OPTION value=17>17</OPTION>
<OPTION value=18>18</OPTION>
<OPTION value=19>19</OPTION>
<OPTION value=20>20</OPTION>
<OPTION value=21>21</OPTION>
<OPTION value=22>22</OPTION>
<OPTION value=23>23</OPTION>
<OPTION value=24 selected>24</OPTION>
<OPTION value=25>25</OPTION> <OPTION value=26>26</OPTION>
<OPTION value=27>27</OPTION>
<OPTION value=28>28</OPTION> <OPTION value=29>29</OPTION> <OPTION value=30>30</OPTION> <OPTION value=31>31</OPTION> </SELECT>&nbsp; <SELECT class="textbox">
<OPTION value="April 2004" selected>Apr 2004</OPTION>
<OPTION value="May 2004">May 2004</OPTION>
<OPTION value="June 2004">Jun 2004</OPTION>
<OPTION value="July 2004">Jul 2004</OPTION>
<OPTION value="August 2004">Aug 2004</OPTION>
<OPTION value="September 2004">Sep 2004</OPTION>
<OPTION value="October 2004">Oct 2004</OPTION>
<OPTION value="November 2004">Nov 2004</OPTION>
<OPTION value="December 2004">Dec 2004</OPTION>
<OPTION value="January 2005">Jan 2005</OPTION>
<OPTION value="February 2005">Feb 2005</OPTION>
<OPTION value="March 2005">Mar 2005</OPTION>
<OPTION value="April 2005">Apr 2005</OPTION>
<OPTION value="May 2005">May 2005</OPTION>
<OPTION value="June 2005">Jun 2005</OPTION>
<OPTION value="July 2005">Jul 2005</OPTION>
<OPTION value="August 2005">Aug 2005</OPTION>
<OPTION value="September 2005">Sep 2005</OPTION>
<OPTION value="October 2005">Oct 2005</OPTION>
<OPTION value="November 2005">Nov 2005</OPTION>
<OPTION value="December 2005">Dec 2005</OPTION>
<OPTION value="January 2006">Jan 2006</OPTION>
<OPTION value="February 2006">Feb 2006</OPTION>
<OPTION value="March 2006">Mar 2006</OPTION>
<OPTION value="April 2006">Apr 2006</OPTION>
</SELECT><br /><br />


<strong>Surname:</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="surname" SIZE="20"><br />
<strong>First Name(s):</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="firstname" SIZE="20"><br />
<strong>Address 1:</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="address1" SIZE="20"><br />
<strong>Address 2:</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="address2" SIZE="20"><br />
<strong>Address 3:</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="address3" SIZE="20"><br />
<strong>Postcode/Zipcode:</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="zip" SIZE="20"><br />
<strong>Telephone:</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="telephone" SIZE="20"><br />
<strong>Email:</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="email" SIZE="20"><br />
<strong>Fax:</strong>&nbsp;&nbsp;
<INPUT class="textbox" TYPE="text" NAME="fax" SIZE="20"><br /><br />




</div>
<div class="reservationsrightdiv">

<select class="textbox" name="numberOfSingleRooms"> <option selected="selected">0</option><option>1</option><option>2</option><option>3</option><option>4</option></select>&nbsp;&nbsp; <strong>Single: </strong><br />

<select class="textbox" name="numberOfTwinRoomsS_occ"> <option selectED="selectED">0</option><option>1</option><option>2</option><option>3</option><option>4</option></select>&nbsp;&nbsp; <strong>Twin: (Single Occ)</strong>
<br />


<select class="textbox" name="numberOfTwinRoomsF_occ"> <option selectED="selectED">0</option><option>1</option><option>2</option><option>3</option><option>4</option></select>&nbsp;&nbsp; <strong>Twin: (Full Occ)</strong>
<br />

<select class="textbox" name="numberOfDoubleRoomsS_occ"> <option selectED="selectED">0</option><option>1</option><option>2</option><option>3</option><option>4</option></select>&nbsp;&nbsp; <strong>Double: (Single Occ)</strong>
<br />

<select class="textbox" name="numberOfDoubleRoomsD_occ"> <option selectED="selectED">0</option><option>1</option><option>2</option><option>3</option><option>4</option></select>&nbsp;&nbsp; <strong>Double: (Full Occ)</strong>
<br /><br />






<!--ADDITIONAL REQUIREMENTS-->
<strong>AdditionalRequests</strong><br />
<textarea class="textbox" cols="26" rows="6" name="AdditionalRequirements"></textarea>
<!--END OF ADDITIONAL REQUIREMENTS--><br /><br />

<input class="submitbuttons" type="button" onClick="javascript:checkFields();" value="Submit">

<input class="submitbuttons" type="reset" value="Start over" name="B2">
</form>
</div>



<div class="bottomdiv"><p class="addressbox">$dpt_address</div>

</body>

</html>
);
}

sub result {
my $msg;
$msg .= "Reservation for: $dpt_name\n";
foreach (@fields) {
$msg .= join(': ',$_,$query->param("$_"))."\n";
}
sendmail($msg);
print qq(
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>$dpt_name</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="stylesheet" href="c:/ireland/ireland_2003/style_perlflypage_validated_new.css" type="text/css">


</script>

</head>

<body>

<div class="header">
<a href="$dpt_url"><img class="premiseslogo" src="$dpt_img" alt=""></a>

<a href="$dpt_hyperlink1"> <img class="th1" src="$dpt_thumb1" alt="$dpt_name View 1" /></a>
<a href="$dpt_hyperlink2"> <img class="th2" src="$dpt_thumb2" alt="$dpt_name View 2" /></a>
<a href="$dpt_hyperlink3"> <img class="th3" src="$dpt_thumb3" alt="$dpt_name View 3" /></a>
</div>


<p class="textmenubkgrnd"><a class="textmenu" href="$dpt_enquiries">&nbsp;Contact $dpt_name&nbsp;</a>&nbsp;<a class="textmenu" href="$dpt_reservations">&nbsp;Bookings&nbsp;</a>&nbsp;<a class="textmenu" href="$dpt_intro">&nbsp;Introduction&nbsp;</a>&nbsp;<a class="textmenu" href="$dpt_findus">&nbsp;Find Us&nbsp;</a>&nbsp;<a class="textmenu" href="$dpt_tellafriend">&nbsp;Tell A friend&nbsp;</a>&nbsp;<a class="textmenu" href="http://www.ireland-info.com/sitemap.htm">&nbsp;Sitemap&nbsp;</a>&nbsp;<a class="textmenu" href="http://www.ireland-info.com">&nbsp;Home Page&nbsp;</a></p>

<div class="centerdiv">

<p class="enquiryform"><br /><br /><br /><br /><strong>Thank you.</strong> Your Reservation Enquiry has been submitted to $dpt_name . They will reply to you directly.<br /><br /><a class="standardlink" href="$dpt_html">Return to $dpt_name.</a></p>


</div>
<div class="bottomdiv">
<p class="addressbox">&nbsp;&diams; &nbsp;$dpt_address&nbsp;&diams; &nbsp;</p>
</div>

</body>

</html>

);
}

sub sendmail {
open(MAIL,"|$mail_prog -t") or die print "Fail to open sendmail: $!\n";
print MAIL "To: $dpt_email\n";
print MAIL "From: ".$query->param('email')."\n";
print MAIL "CC: $recipient\n";
print MAIL "Subject: $subject\n\n";
print MAIL $_[0];
close(MAIL);
}


Bazz

stry_cat
08-12-2004, 04:50 PM
You should be able to double click the error icon in the status bar. IE should tell you more about the error. The Perl is probably correct so I'm guessting it is the DHTML that it is generating.

I'd also see what it does in Mozilla or Netscape.

bazz
08-12-2004, 06:07 PM
Oh thanks, I'll try that when I get home. I should have said that the file is supposed to check that surname first namne and email are completed before the submission is allowed - but it isnt, on my machine anyway.

Bazz

I'm a dipstick!! The fields that the script is trying to check for are not named correctly. I'll fix that before troubling you guys again.