[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

6.2

Reservation script - further modifications

Asked by rowby in Perl Programming Language

Tags: reservation, script

Hello class.  

I need further modifications on the reservation script called by this page (it is not live on the site, so feel free to test:

http://www.laxautopark.com/reservations.shtml

(note the years are now hidden fields, and I added two fields phone and comments which are not "live" yet.

First the easy part.  I want the two time fields ("Time you will arrive to park your car:" and "Time you will be returning to pick up your car:*" to have the am and pm's built in, as on the following page (which IS live):

http://foxrentacar.com/rates_reservations.html

Also, for some reason if you make a reservation for a date EARLIER than today's date at:

http://www.laxautopark.com/reservations.shtml

...you get the following message:

Can't locate object method "after" via package "current" at /home/sites/site24/web/cgi-bin/reservation.cgi line 151.

Now it *may* be I uploaded an earlier script but I doubt it.  So please double check the script which I am posting at the end of this question.

Also if you put in your first name, last name and email address but do NOT enter a date and leave the rest of the form blank, you get the following message:

Day 'Day' out of range 1..31 at /home/sites/site24/web/cgi-bin/reservation.cgi line 134

I would rather a user friendly message appear.

Here is the script as is on the site:

#!/usr/bin/perl

$|++;

print "Content-type: text/html\n\n";

use CGI;
use Time::Local;

##     Full path to the sendmail file.
$mailprog ="/usr/sbin/sendmail";

###  Full path to the dates file
$date_file="date.txt";

if (-e $date_file){
     ##     Read the entire list of blocked dates.
     open(DF,$date_file) || die $!;
     flock(DF, 1) || die $!;     ##     Open the file in a shared, read-only mode.
     while(<DF>){
          chomp;
          $line{$_}++;
     }
     close(DF);
}

##     Required for date validations
%mon2num=('JAN' => 0,
'FEB' => 1,
'MAR' => 2,
'APR' => 3,
'MAY' => 4,
'JUN' => 5,
'JUL' => 6,
'AUG' => 7,
'SEP' => 8,
'OCT' => 9,
'NOV' => 10,
'DEC' => 11
);

##     Full path to the comma-delimited output file.
$out_file='/tmp/comma_out';

##     Full path to the counter file.
$ctr_file='/tmp/ctr';

##     Hard-coded from email id
$from='rowby@rowby.com';

##     Hard-coded of the Rental company
$cc='rowby@rowby.com';

##     Create a new CGI object
$query=new CGI;

##     Read the incoming HTML form elements.
foreach ($query->param){
     $$_=$query->param($_);

     ##     Remove leading & trailing whites spaces
     $$_=~ s/^\s+//;
     $$_=~ s/\s+$//;
     ##     Squeeze multiple white spaces into a single space.
     $$_=~ s/\s+/ /g;
}

##     Set default value for Corporate Code
$TACode='None' if (!($TACode));

##     Placeholder for doing all data validations here
my($error_flag)=0;

if (!($FirstName) && length($FirstName)<=0){     ##     Empty!!
     print "<B>Please enter your first name. </B><P>\n";
     ++$error_flag;
}

if (!($LastName) && length($LastName)<=0){     ##     Empty!!
     print "<B>Please enter your last name.</B><P>\n";
     ++$error_flag;
}

if (!($DepartMonth) && length($DepartMonth)<=0){     ##     Empty!!
     print "<B>Please select the month you will be leaving your car.</B><P>\n";
     ++$error_flag;
}

if (!($DepartDay) && length($DepartDay)<=0){     ##     Empty!!
     print "<B>Please select the day you will be leaving your car.</B><P>\n";
     ++$error_flag;
}

if (!($yeardropoff) && length($yeardropoff)<=0){     ##     Empty!!
     print "<B>Please select a year for departure.</B><P>\n";
     ++$error_flag;
}

if (!($DepartHour) && length($DepartHour)<=0){     ##     Empty!!
     print "<B>Please select the hour you will be leaving your car.</B><P>\n";
     ++$error_flag;
}

if (!($ReturnMonth) && length($ReturnMonth)<=0){     ##     Empty!!
     print "<B>Please select the month you you be picking up your car.</B><P>\n";
     ++$error_flag;
}

if (!($ReturnDay) && length($ReturnDay)<=0){     ##     Empty!!
     print "<B>Please select the day you will be picking up your car.</B><P>\n";
     ++$error_flag;
}

if (!($yearreturn) && length($yearreturn)<=0){     ##     Empty!!
     print "<B>Please select a year for Return</B><P>\n";
     ++$error_flag;
}

if (!($ReturnHour) && length($ReturnHour)<=0){     ##     Empty!!
     print "<B>Please enter the hour you will be picking up your car.n</B><P>\n";
     ++$error_flag;
}

if (!($Email) && length($Email)<=0){     ##     Empty!!
     print "<B>Please enter an Email address.</B><P>\n";
     ++$error_flag;
}

exit if $error_flag;  ##  Stop!! We have errors.

##     Do advanced date validations here.
$yeardropoff-=1900;     ##     Remove 1900 from the year.
$CMONTH=$mon2num{uc($DepartMonth)};
$Time1 = timelocal(0,0,$DepartHour,$DepartDay,$CMONTH,$yeardropoff);
$Depart_Time1 = timelocal(0,0,0,$DepartDay,$CMONTH,$yeardropoff);

$yearreturn-=1900;     ##     Remove 1900 from the year.
$DMONTH=$mon2num{uc($ReturnMonth)};
$Time2 = timelocal(0,0,$ReturnHour,$ReturnDay,$DMONTH,$yearreturn);

if ($Time1 >= $Time2){ ##     Stop!! Departure date cannot be after Return date.
     print "<B>Departure Date-time <U>MUST</U> be earlier than Return Date-Time</B><P>\n";
     ++$error_flag;
}

##     Now get the current date time.
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
$Time_now=timelocal(0,0,$hour,$mday,$mon,$year);

if (($Time1 - (30 *60)) <= $Time_now){ ##     Stop!! Departure date must be at least 30 mins difference
after current date-time.
     print "<B>Departure Date-time <U>MUST</U> be at least 30 minutes after current date-time</B><P>\n";
     ++$error_flag;
}

exit if $error_flag;     ##     Stop!! We have errors.

print "<!--Departure time = $Depart_Time1-->\n";

##     Now check if the Start date has been blocked.
if ($line{$Depart_Time1}){     ##     Blocked!!

     print qq{
     The Departure date that you selected ($DepartMonth/$DepartDay/},($yeardropoff+1900),qq{) has been blocked.
     <P>
     Click <A HREF="javascript:history.go(-1)"><B>here</B></A> to select a different Departure date!!
     };
     exit ;     ##     Stop!! We have a blocked date!!
}

##     End of placeholder for doing all data validations here


##     Now that data validation is completed, successfully, we will increment the counter.
##     Check if the counter file exists.
if (open(CTR,$ctr_file)){     ##     Exists. Use it!!
##     Open the file with a shared lock, to prevent simultaneous access.
flock(CTR,1) || die $!;
$counter=<CTR>;     ##     Read the counter.
chomp($counter);     ##     Remove the newline character.
}else{     ##     Does not exist. Create one!!
$counter=1000;     ##     Lets start from this number.
}

close(CTR);

##     Increment the counter.
$counter++;

##     Now write this new value back to the file.
open(CTR,"> $ctr_file")|| die $!;
##     But remember to lock this file for exculsive use, to prevent simultaneous access.
flock(CTR,2) || die $!;
print CTR     $counter."\n";
close(CTR);

##     Now write this new record to the comma-delimited file.
open(DELIM,">> $out_file")|| die $!;
##     But remember to lock this file for exculsive use, to prevent simultaneous access.
flock(DELIM,2) || die $!;

print DELIM join(',',$counter,$FirstName,$LastName,$DepartMonth,$DepartDay,$DepartHour.':'.$DepartMinute.'






'.$DepartDT,$ReturnMonth,$ReturnDay,$ReturnHour.':'.$ReturnMinute.' '.$ReturnDT,$Email,$Zip)."\n";

close(DELIM);

##     Start sending out the emails!!
open(MAIL, "| $mailprog -t ") || die $!;
print MAIL "To: $Email\n";
print MAIL "From: $from\n";
print MAIL "Subject: Confirmation e-mail from Rowby (# $counter)!\n";
print MAIL qq{

Thank You for your Parking Reservation

Please print this page out for your reference.

We have emailed a confirmation email to the address you provided in your form.

CONFIRMATION NUMBER: $counter

Name: $FirstName $LastName

Departure date: $DepartMonth $DepartDay,}.($yeardropoff+1900).qq{, $DepartHour:$DepartMinute $DepartDT

Return date: $ReturnMonth $ReturnDay,}. ($yeardropoff+1900).qq{, $ReturnHour:$ReturnMinute $ReturnDT

Email address: $Email

Zip code: $Zip

Corporate code: $TACode
};

close(MAIL);

### rowby added below

##     Start sending out the emails!!
open(MAIL, "| $mailprog -t ") || die $!;
print MAIL "To: rowby\@foxrentacar.com\n";
print MAIL "From: $from\n";
print MAIL "Subject: To LAX Reservation Dept (# $counter)!\n";
print MAIL qq{

A reservation has been made on the LAXAUTOPARK Website.

Please print this page out for your reference.

We have emailed a confirmation email to the address you provided in your form.

CONFIRMATION NUMBER: $counter

Name: $FirstName $LastName

Departure date: $DepartMonth $DepartDay,}.($yeardropoff+1900).qq{, $DepartHour:$DepartMinute $DepartDT

Return date: $ReturnMonth $ReturnDay,}. ($yeardropoff+1900).qq{, $ReturnHour:$ReturnMinute $ReturnDT

Email address: $Email

Zip code: $Zip

Corporate code: $TACode
};

close(MAIL);
###  end of rowby

##     Now that we have sent the email out, lets print the HTML page.
print qq{
<p align="center"><font face="Arial, Helvetica, sans-serif" size="3"><b>Thank
You for your Parking Reservation</b></font>
<p align="center"><font face="Arial, Helvetica, sans-serif" size="3">Please
print this page out for your reference.</font>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">We
have emailed a confirmation email to the address you provided in
your form.</font>
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left"><b><font face="Arial, Helvetica, sans-serif">CONFIRMATION
NUMBER: $counter</font></b>
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left">
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Name:
$FirstName $LastName</font>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Departure  date: $DepartMonth $DepartDay,
}. ($yeardropoff+1900).qq{, $DepartHour:$DepartMinute $DepartDT</font>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Return date: $ReturnMonth $ReturnDay,
}. ($yearreturn+1900).qq{, $ReturnHour:$ReturnMinute $ReturnDT</font>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Email
address: $Email</font>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Zip
code: $Zip</font>
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3">Corporate
code: $TACode</font>
<p align="left">
<p align="left">
<p align="left">
<p align="center"><br>
</p>
};


 

 
Related Solutions
 
Loading Advertisement...
 
[+][-]01/09/02 01:47 PM, ID: 6721933Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Perl Programming Language
Tags: reservation, script
Sign Up Now!
Solution Provided By: maneshr
Participating Experts: 2
Solution Grade: A
 
[+][-]01/07/02 12:13 PM, ID: 6716012Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/07/02 02:23 PM, ID: 6716283Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/07/02 02:58 PM, ID: 6716347Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/07/02 04:42 PM, ID: 6716518Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/07/02 04:45 PM, ID: 6716525Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/07/02 05:44 PM, ID: 6716638Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/07/02 07:36 PM, ID: 6716744Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/07/02 07:40 PM, ID: 6716749Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/07/02 07:45 PM, ID: 6716758Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/07/02 07:47 PM, ID: 6716761Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/07/02 08:32 PM, ID: 6716833Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/08/02 06:52 AM, ID: 6717870Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/08/02 07:00 AM, ID: 6717895Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/08/02 08:48 AM, ID: 6718307Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/08/02 07:41 PM, ID: 6719672Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/08/02 08:06 PM, ID: 6719691Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/08/02 08:11 PM, ID: 6719697Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/08/02 08:15 PM, ID: 6719702Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/09/02 05:18 AM, ID: 6720459Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/09/02 07:49 AM, ID: 6720898Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/09/02 07:55 AM, ID: 6720924Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/09/02 01:22 PM, ID: 6721866Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/09/02 01:59 PM, ID: 6721964Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/09/02 02:05 PM, ID: 6721975Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]01/09/02 02:17 PM, ID: 6721994Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]01/09/02 03:36 PM, ID: 6722174Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20091118-EE-VQP-93