#native_company# #native_desc#
#native_cta#

car rental online reservation script

By markl
on September 15, 2001

Version: 1.00

Type: Full Script

Category: Databases

License: GNU General Public License

Description: this is a car rental online reservation script utilizing freesql.org’s (http://www.freesql.org) mysql server.

<html>
<head>
        <title>Online Reservation</title>
        <!--company x online reservation created by Mark Anthony R. Lisao-->
</head>

<?

//note : $first_pass variable is hidden in the form

empty($first_pass) ?
       show_form() :
       data_keep($first_name, $last_name, $email, $address, $contact_no,
                 $units_sedan, $units_pickup, $units_van, $month, $day,
                 $year, $inquiries);
       exit;
?>

<?
function untaint($x){
         chop($x);
         $x=strtolower($x);
         $x=ereg_replace("[!#$%^()+=<>]", "", $x);
         return $x;
                 //clean up user input data
}

function data_keep($d1, $d2, $d3, $d4, $d5,
                   $d6, $d7, $d8, $d9, $d10,
                   $d11, $d12){

         $arr=array("first_name" => $d1,
                    "last_name" => $d2,
                    "email_address" =>  $d3,
                    "business_address" => $d4,
                    "contact_no" => $d5
                   );

                   //error handler
         $empty_vals=array();
         while (list($key, $value )=each($arr)){
                untaint($value);
                if($value==""){
                    array_push($empty_vals, $key);
                }
         }

         if (empty($empty_vals)){
                    //establishing database connection
             $db_loc=mysql_connect("freesql.org", "markl", "asia12");
             mysql_select_db("markl", $db_loc);

             $query="INSERT INTO crc_data (first_name, last_name, email, address, contact_no,
               units_sedan, units_pickup, units_van, month, day,
               year, inquiries) VALUES
               ('$d1', '$d2', '$d3', '$d4', '$d5',
                '$d6', '$d7', '$d8', '$d9', '$d10',
                '$d11', '$d12')";

               mysql_query($query);
                   //entry succesfully added

              echo("<p style=font-family:arial font-size:2>");
              echo("Your reservation has been processed. We shall update you soon about your booking.");
              echo("<br>Thank you very much.</p>");
              echo("<a href='http://www.markl001ph.host.sk'>Back to main page</a>");
         }
         else{
                  global $PHP_SELF;
$err_html=<<<EOL
                  <p style="font-family:arial font-size:2">
                  Error on Form.<br>
                  You had error(s) on the following fields :
EOL;
                  echo ($err_html." ");
                  for ($i=0; $i<count($empty_vals); $i++){
                        echo ($empty_vals[$i].", ");
                  }
                  echo("<br><a href=".$PHP_SELF.">Back to form</a>");
                  echo("</p>");
         }

}
function show_form(){

        global $PHP_SELF;

$form=<<<HTML

        <body>
        <div align="center">

        <form action="$PHP_SELF">

        <input type="HIDDEN" name="first_pass" value="no">
        <table>
                       <tr>
                           <td colspan="2">Customer Information</td>
                       </tr>
                       <tr>
                           <td>First Name </td><td><input type="text" size="15" name="first_name" maxlength="40"></td>
                       </tr>
                       <tr>
                           <td>Last Name </td><td><input type="text" size="20" name="last_name" maxlength="40"></td>
                       </tr>
                       <tr>
                           <td>Email </td><td><input type="text" size="20" name="email" maxlength="40"></td>
                       </tr>
                       <tr>
                           <td>Business Address</td><td><input type="text" size="30" name="address" maxlength="80"></td>
                       </tr>
                       <tr>
                           <td>Contact Number</td><td><input type="text" size="18" name="contact_no" maxlength="20"></td>
                       </tr>
                       <tr>
                           <td colspan="2">&nbsp;</td>
                       </tr>

        </table>
        <table>
                       <tr>
                           <td colspan="2">Vehicle Reservation</td>
                       </tr>
                       <tr>
                           <td>Vehicle Type</td><td>Number of Units</td>
                       </tr>
                       <tr>
                           <td>Sedan</td><td><select name="units_sedan">
                                       <option value="0">0
                                       <option value="1">1
                                       <option value="2">2
                                       <option value="3">3
                                       <option value="4">4
                                       <option value="5">5
                                       </select>
                           </td>
                       </tr>
                       <tr>
                           <td>Pickup</td><td><select name="units_pickup">
                                       <option value="0">0
                                       <option value="1">1
                                       <option value="2">2
                                       <option value="3">3
                                       <option value="4">4
                                       <option value="5">5
                                       </select>
                           </td>
                       </tr>
                       <tr>
                           <td>Van</td><td><select name="units_van">
                                       <option value="0">0
                                       <option value="1">1
                                       <option value="2">2
                                       <option value="3">3
                                       <option value="4">4
                                       <option value="5">5
                                       </select>
                           </td>
                       </tr>
                       <tr>
                            <td>Reservation Date</td>
                            <td><select name="month">
                                <option value="jan">January
                                <option value="feb">February
                                <option value="mar">March
                                <option value="apr">April
                                <option value="may">May
                                <option value="jun">June
                                <option value="jul">July
                                <option value="aug">August
                                <option value="sep">September
                                <option value="oct">October
                                <option value="nov">November
                                <option value="dec">December
                                </select>
                            </td>
                            <td>
                                <select name="day">
                                <option value="1">1
                                <option value="2">2
                                <option value="3">3
                                <option value="4">4
                                <option value="5">5
                                <option value="6">6
                                <option value="7">7
                                <option value="8">8
                                <option value="9">9
                                <option value="10">10
                                <option value="11">11
                                <option value="12">12
                                <option value="13">13
                                <option value="14">14
                                <option value="15">15
                                <option value="16">16
                                <option value="17">17
                                <option value="18">18
                                <option value="19">19
                                <option value="20">20
                                <option value="21">21
                                <option value="22">22
                                <option value="23">23
                                <option value="24">24
                                <option value="25">25
                                <option value="26">26
                                <option value="27">27
                                <option value="28">28
                                <option value="29">29
                                <option value="30">30
                                <option value="31">31
                                </select>
                            </td>
                            <td>
                                <select name="year">
                                <option value="2001">2001
                                <option value="2002">2002
                                <option value="2003">2003
                                </select>
                            </td>
                       </tr>
        </table>
        <table>
                       <tr>
                            <td>Inquiries/Trip Details </td><td>&nbsp;</td>
                       </tr>
                       <tr>
                            <td colspan="2"><textarea name="inquiries" cols="42" rows="7"></textarea></td>
                       </tr>
                       <tr>
                            <td><input type="submit" value="submit entries">&nbsp;<input type="reset" value="clear"></td>
                       </tr>
        </table>
        </form>
        </body>
        </html>

HTML;
echo $form;
}
?>