PHP - What's The Best Way To Create A Booking Calendar System?
Here's what I'm trying to do. 1. A user creates a calendar that shows which dates he's available. This calendar could showcase availability for up to a year. 2. Other users can do a search for a user that's available on a set date. For e.g. July 1st. 3. All the users available on July 1st will show up in the search results.
There is no booking for appointments involved. It simply needs to show the users available on set dates. I am wondering what's the best way to create this calendar feature? Similar TutorialsHi, As a part of my university course final year project i have to create a room reservation system. I have found this http://www.phpjabbers.com/availability-booking-calendar/index.php Which looks perfect but i cant use that as i have to code it myself. Does anyone know of a guide that will help me build something similar? Thanks in advance Hello. I'm trying to build a site where users can book appointments with personal trainers. I want to use the free and open source jQuery Full Calendar for the look and feel of the calendar since it looks pleasant and is responsive. <link removed> I want each personal trainer to have their own calendar which will show the days that they're available. When a user clicks on an available day then they will see a list of time slots that they can book in 15 minute increments. So, for instance lets say a trainer named Mike is available on Mondays-Friday from 8am-5pm. If a user comes to his calendar they will see that certain days are not fully booked and they can click on a day. Then when they click on a day they can see time intervals like this: Mike's available time slots for Tuesday August 25, 2014: 8:00 am-9:00 am - Click here to book appointment! 8:15 am-9:15 am - Click here to book appointment! 2:00 pm - 3:00 pm - Click here to book appointment! The page above can be a separate page from the calendar, but it would need to be synced with the calendar to be able to fetch the times and days that he's available for appointments. Then when the user clicks on a day, he can book an appointment and after the trainer confirms via email then the user will receive an email confirmation that his appointment is scheduled. While it's still being confirmed though, that time slot would need to be no longer visible to other users, so that there wouldn't be multiple bookings for the same time slot, to avoid those conflicts. So, the application would need to fetch the data from MySQL and use that to display the available days. If a day is not available then the user will not be able to click on it in the calendar. Also, the trainers should be able to set their schedule which will get updated to MySQL, so the schedule is normally recurring but they should also be able to change certain days if they feel like they can or cannot work on that day. Also, the appointments will vary by time, so a training session can last 30 minutes, 1 hour, 3 hours, 1 hour and a half, etc. and that would need to be taken into account when the user books an appointment because if the trainer has a 1 hour gap between 2pm and 3pm, but the session is for 2 hours, they should not be able to book that time slot, since it wouldn't make any sense. What makes this complicated is that the appointment lengths can vary. Otherwise, if every appointment was 1 hour long I would be able to just create a table for appointment times and do a query to see if they're booked and only show the booked ones. How can I do it with variable time lengths? Any help would be greatly appreciated. Edited by mac_gyver, 16 August 2014 - 09:04 AM. removed link, not relevant to post Hi All I am wanting to create an online booking system. Has anyone got any suggestions on this? Adi Hi there Got a problem needs a solution, basically a booking system has been built (by me) and works great except for the checking availablity Basically they can do drives in a car (in any order) so I need to try all possible combinations. one idea I had was to use an array holding the availability for each slot so that it looks like slotArray=array("ABC","AC","C","A","BC","AB","ABC" ...etc) looking for drives A and B so check if slotArray[1] contains A and Slot Array 2 contains b or vice versa what i need to do is work out all the possible orders of a string ABCDE (there will be 120 of them) so I can systematically check the order anyone have a function that will do this? Hi, I want to check entered dates and times that a user selects against my "book-off" calendar which is a Google Calendar. The dates× from Google is in the form: 2011-04-29T23:00:00.000+02:00 The dates in my booking software (ABPro) is in the form: 2011-04-29 Times in form: 23:00:00 All I want the function to return is a number other than 0 if any of the dates/times in Google feed overlap the requested date/time entered in the booking. So I add a function and get the feed from Google: Code: [Select] function checkOverlapG($calendarID, $startdate, $starttime, $enddate, $endtime){ // Create an instance of the Calendar service using an unauthenticated //HTTP client $service = new Zend_Gdata_Calendar(); //Retrieving events in order of start time $query = $service->newEventQuery(); $query->setUser('calendarID'); // Set to $query->setVisibility('private-magicCookieValue') if using MagicCookie auth $query->setVisibility('public'); $query->setProjection('full'); $query->setOrderby('starttime'); $query->setSortOrder('ascending'); //start with first event in future //seFutureevents must be commented out when using start and end times. $query->setFutureevents('true'); $query->setSingleEvents('true'); $query->setMaxResults('200'); //Guess this could be anything, but can possibly make things slower. Default 25 events //$query->setStartMin('2006-12-01'); //$query->setStartMax('2006-12-16); // setStartMax is exclusive, will not include last date. Must add +1 day. // Retrieve the event list from the calendar server try { $eventFeed = $service->getCalendarEventFeed($query); } catch (Zend_Gdata_App_Exception $e) { echo "Error: " . $e->getMessage(); return null; } Now I want to compare the dates and times and see if any of them collide or overlap. I want to add a counter, and if any of the events overlap, I want the counter to add one number. 1. the first thing I do is check if the event feed include. any events. 2. then I add a counter 3. then I run a foreach to retrieve events one at a time 4. then I change the date and time format from Google Event to match the date and time format form the booking. 5. If fullday event from google, no time information is added, so I add this 6. COMPARE DATES AND TIMES and if overlapping events --> n++; I've not gotten this code to work. Probably I'm doing something wrong, and I'm sorry but I'm completely new to this. Getting the Google Calendar data is working fine, and so is changing the format of the dates/times to be same format as request data. After that (and before, I don't know). Code: [Select] $gCount = count($eventFeed); $n = 0; if (gCount>0){ foreach($eventFeed as $event){ foreach ($event->when as $when) { //Getting rid of extra 00's and time zone info for now $startGevent = $when->startTime; $startGevent = str_replace('.000+02:00',"",$startGevent); $endGevent = $when->endTime; $endGevent = str_replace('.000+02:00',"",$endGevent); //Splitting date and time into two variables list($startDateEvent, $startTimeEvent) = split('T',$startGevent); list($endDateEvent, $endTimeEvent) = split('T',$endGevent); //Fill in the blanks if($startTimeEvent!=0) {} else{$startTimeEvent = "00:00:00";} if($endTimeEvent!=0) {} else{$endTimeEvent = "00:00:00";} //Compare dates if($startdate == $endDateEvent){ if($starttime > $endTimeEvent OR $endtime < $startTimeEvent){} else { n++; } } if($enddate == $startDateEvent){ if($endtime < $startTimeEvent OR $starttime > $endTimeEvent){} else { n++; } } } } return $n; } Well so far i've found myself in a hole on a few different methods, basically my system is sold with a key. The issue i am having is, everyone that is purchasing the software uses free hosting, basically no PHP Curl allowed, and no file_get_contents with urls allowed. Now, i thought i had it and i was happy for a day. until i moved it to a different server just to find Javascript was not my answer by getting content from an iframe due to security issues its not allowed...yay.. So is there any other way i can get around this? i mean there are tons of scripts out there with key systems set, so if the key is changed on the users site or the website url is not the same as the installed url. then it blanks the website to text. Everything works fine, the functions are 100% go. i just can't get content from a url if the hosts won't allow it. there needs to be some other way this has to be possible? PHPCurl, is a no go, 80% free hosts block this. file_get_contents won't work if you place url's in majority of the free webservers. [stuck] Hi Guys, have you got an idea how I can create a user management system with login and pw, please? I tried the below, but when I click on the "ADD NEW USER" button nothing happens <div> <fieldset> <legend>USER DETAILS</legend> <table> <tr> <td align="right"><a title='NAME' href='user_edit.php?id=1'>NAME</a></td> <td> <input class="norm" type="text" name="name" id="name" /></div> </td> <td align="right"><a title='SURNAME' href='user_edit.php?id=2'>SURNAME</a></td> <td> <input class="norm" type="text" name="surname" id="surname" /></div> </td> </tr> <tr> <td align="right"><a title='E-MAIL ADDRESS' href='user_edit.php?id=3'>E-MAIL ADDRESS</a></td> <td colspan="4"> <input class="norm" type="text" size="57" name="e-mail" id="e-mail" /></div> </td> </tr> <tr> <td align="right"><a title='LOGIN' href='user_edit.php?id=4'>LOGIN</a></td> <td> <input type="text" name="login" id="login" /></div> </td> <td align="right"><a title='PASSWORD' href='user_edit.php?id=5'>PASSWORD</a></td> <td> <input class="norm" type="text" name="password" id="password" /></div> </td> </tr> </table> </fieldset> </div> <br /> <div> <fieldset> <input type='submit' name='delete' value='DELETE USER' onclick='confirm("ARE YOU SURE?");'/> <input type='submit' name='add' value='ADD NEW USER'/> </fieldset> </div> cheers, ozzo Hi guys, I am thinking of create an free email system by sending an messages using with a username. Would I have to store the messages via in mysql? If I can do that, then I just curious that how would a user delete their messages if their messages is display on php page? What method would I have to use? I currently have a MyBB forum and I'm going to attempt to create a top list for it, but I'd like users that have already registered on my forum to be able to log into the top list area and either add or edit their website on the top list. How would I go about creating a login script with an already existing MySQL database that contains my MyBB users? hello, i have a booking form that allows people to book appointments from 0900 to 1800 with 30 min intervals 0900,0930,1000 etc and i was wondering if there is some php code out there that will stop people from booking an appointment at a time that is already booked. any ideas ? cheers I'm new to this blog but need serious help. I want to add a calendar to a Hotel website for the booking part, I did it once but I forgot how to do it. Here is the link to the booking file. http://regencycountryclub.com/QuickReserve.php I just want instead of having to select the day, month and year. I want to add a calendar to select the arrival date and departure date. I would really appreciate the help. Thanks Hi all I am trying to edit a piece of code to change possible times for a booking system. This is the code I have: $count=0; for($b=$startTime;$b<$endTime;$b++){ if($count==$tempVar2){ $availability .= "</td><td align='left' valign='top'>"; } if(in_array($b,$reservedArray)){ $availability .= $b.":00 ".($b<12?"am":"pm")." - ".($b+1).":00 ".($b+1<12?"am":"pm")." - Booked.<br>"; } else { $availability .=$b.":00 ".($b<12?"am":"pm")." - ".($b+1).":15 ".($b+1<13?"am":"pm")."- <input type=\"checkbox\" value=\"".$b."\" name=\"time[]\" ><br>"; } $count++; } It gives me the following times: 09:00 am - 10:15 am 10:00 am - 11:15 am 11:00 am - 12:15 am 12:00 pm - 13:15 pm 13:00 pm - 14:15 pm 14:00 pm - 15:15 pm 15:00 pm - 16:15 pm 16:00 pm - 17:15 pm How can I change it so I can have the following times available: 10:00 am - 10:30 am 10:45 am - 11:15 am 11:30 am - 12:00 pm 12:15 pm - 12:30 pm etc... Many thanks for you help Pete. i have installed a calendar i want to extract the available id_item that are not id_state=1(booked) i want to query all the items that are not booked the dates: $fromdate=22-03-2011; $todate=25-03-2011; Code: [Select] this is bookings.php mysql_select_db($database_international, $international); $query_RsBookingIO = sprintf("SELECT * FROM `bookings` LEFT JOIN bookings_items ON bookings.id_item = bookings_items.id WHERE dateDIFF (2011-03-22, 2011-03-25) and bookings.id_state ='1' LIMIT 0 , 30 ", GetSQLValueString($colname_RsBookingIO, "int")); $RsBookingIO = mysql_query($query_RsBookingIO, $international) or die(mysql_error()); $row_RsBookingIO = mysql_fetch_assoc($RsBookingIO); <?php do { echo $row_RsBookingIO['the_date']; ?> <?php } while ($row_RsBookingIO = mysql_fetch_assoc($RsBookingIO)); ?> now when creating the searchfunction.php <?php $data = file_get_contents('http://localhost/bookings.php?fromdate=$fromdate and todate=$todate'); $fromdate = $_GET['fromdate']; $todate = $_GET['todate']; $dates = explode(' ',$data); var_dump($data); foreach($dates as $aDate) { echo $aDate; //$aDate = '\''.$aDate.'\''; if (!in_array($aDate, $dates)) { $available = true; } } return $available; ?> //tables CREATE TABLE `bookings` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_item` int(20) NOT NULL DEFAULT '0', `the_date` date NOT NULL DEFAULT '0000-00-00', `id_state` int(11) NOT NULL DEFAULT '0', `id_booking` int(10) NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `id_item` (`id_item`), KEY `id_state` (`id_state`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ; -- -- Dumping data for table `bookings` -- INSERT INTO `bookings` VALUES(1, 2, '2011-03-22', 1, 0); INSERT INTO `bookings` VALUES(3, 2, '2011-03-23', 1, 0); INSERT INTO `bookings` VALUES(4, 2, '2011-03-24', 1, 0); INSERT INTO `bookings` VALUES(5, 2, '2011-03-25', 1, 0); INSERT INTO `bookings` VALUES(6, 2, '2011-03-26', 1, 0); INSERT INTO `bookings` VALUES(7, 3, '2011-03-23', 1, 0); INSERT INTO `bookings` VALUES(8, 3, '2011-03-24', 1, 0); INSERT INTO `bookings` VALUES(9, 3, '2011-03-25', 1, 0); INSERT INTO `bookings` VALUES(10, 3, '2011-03-26', 1, 0); INSERT INTO `bookings` VALUES(11, 3, '2011-03-27', 1, 0); CREATE TABLE `bookings_items` ( `id` int(11) NOT NULL AUTO_INCREMENT, `id_user` int(11) NOT NULL DEFAULT '1', `id_ref_external` int(11) NOT NULL COMMENT 'link to external db table', `desc_en` varchar(100) NOT NULL DEFAULT '', `desc_es` varchar(100) NOT NULL DEFAULT '', `list_order` int(11) NOT NULL DEFAULT '0', `state` tinyint(1) NOT NULL DEFAULT '1', PRIMARY KEY (`id`), KEY `id_user` (`id_user`), KEY `id_ref_external` (`id_ref_external`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; -- -- Dumping data for table `bookings_items` -- INSERT INTO `bookings_items` VALUES(1, 1, 4600, 'Suite_A', 'Suite_A', 2, 1); INSERT INTO `bookings_items` VALUES(2, 1, 4601, 'Suite_B', 'Suite_B', 2, 1); hello dear PHP-Fans - greetings to you - and a happy new year!! i set up a WAMP-System on my openSuse 11.4 system. In order to learn as much as i can bout PHP i want to do some tests and write some scripts. Well the WAMP is allready up and running. Now i try to give the writing access to the folder mkdir /srv/www/ where the php-scripts should go in... i want to give write permission to all to all files in /srv/www As root I generally: mkdir /srv/www/ chown <webmaster usrername> /srv/www/ /srv/www/ should be readable and traversable by all, but only writeable by it's owner (the user designated as the webmaster.) can i do this like mentioned above,... Love to hear from you greetings db1 Hello Friends,
I am trying to execute Time slot booking for an application. - When user selects a date - Each time slot can be booked by 2 users User 1 selected a date (2nd March)and selected a time slot (10:00 - 11:00 AM).
User 2 selected a date (2nd March)and selected a time slot (10:00 - 11:00 AM). Please find the script below. Your help is really appreciated. <?php include('database.php'); $fname=""; $lname=""; $email=""; $phone=""; $date=""; if(isset($_POST['fname'])){ $fname=$_POST['fname'];} if(isset($_POST['lname'])){$lname=$_POST['lname'];} if(isset($_POST['email'])){$email=$_POST['email'];} if(isset($_POST['phone'])){$phone=$_POST['phone'];} if(isset($_POST['date'])){$date=$_POST['date'];} else $date=date("m-d-Y") $result=mysqli_query($conn,"SELECT exam_time,count()from test_booking_confirm where DATEDIFF('exam_date',DATE_FORMAT('"+$date+"','%m-%d-%Y'))=0 group by exam_date,exam_time having count()>1"); $slots=array(); $i=0; if (mysqli_num_rows($result) != 0) { while($row = mysqli_fetch_assoc($result)) { $slots[$i]=$row["exam_time"]; $i++; } } ?> <!doctype html> <html> <head> <title></title> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="css/style.css" /> <link rel="stylesheet" href="css/bootstrap.min.css" /> <!-------date picker-------> <link rel="stylesheet" href="css/jquery-ui.css" /> <script src="js/jquery.js"></script> <script src="js/jquery-ui.js"></script> <script> $(document).ready(function(){ $("#datepicker").datepicker({ beforeShowDay: function(date) { var day=date.getDay(); if(day==2) { return [false]; } else { return [true]; } } }); }); </script> <script> $(document).ready(function() { $('#datepicker').datepicker(); $('#datepicker').datepicker("show"); }); </script> <script> function setToday() { var n = new Date(); y = n.getFullYear(); m = n.getMonth() + 1; d = n.getDate(); var x=m + "/" + d + "/" + y; document.getElementById("datepicker").value = x; } function datechange(vv) { document.myform.action="test_booking.php"; document.myform.submit(); } </script> </head> <body OnLoad="document.myform.fname.focus();setToday()"> <div class="container register"> <div class="row"> <div class="col-md-3 training_bk register-left"> <img src="images/ESStechlogo.png" alt=""/> <h3>Welcome</h3> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry.</p> </div> <div class="col-md-9 register-right"> <form method="post" action="test_booking_review.php" name="myform"> <div class="tab-content" id="myTabContent"> <div class="tab-pane fade show active" id="home" role="tabpanel" aria-labelledby="home-tab"> <h3 class="register-heading">Book your Training</h3> <div class="row register-form"> <div class="col-md-6"> <div class="form-group"> <input type="text" autofocus name="fname" required class="form-control" placeholder="First Name*" /> </div> <div class="form-group"> <input type="text" name="lname" required class="form-control" placeholder="Last Name*" /> </div> <h5>Your Preferred Slot</h5> <div class="form-group"> <!--<div id="datepicker" required name="date" ></div>--> <input type="text" id="datepicker" required name="date" placeholder="mm/dd/yyyy" class="form-control" onChange ="datechange(this.value)"> </div> </div> <div class="col-md-6"> <div class="form-group"> <input type="email" name="email" required class="form-control" placeholder="Email*" /> </div> <div class="form-group"> <input type="number" name="phone" required class="form-control" placeholder="Phone*" /> </div> <!--<div class="form-group"> <select class="form-control"> <option class="hidden" selected disabled>City</option> <option>option</option> <option>option</option> <option>option</option> </select> </div>--> <div class="form-group"> <div class="maxl"> <?php if (!in_array("08:00AM TO 09:00AM", $slots)) { ?> <label class="radio inline"> <input type="radio" name="time" value="08:00AM TO 09:00AM" checked> <span>08:00AM TO 09:00AM (Available)</span> </label> <?php } if (!in_array("09:00AM TO 10:00AM", $slots)) { ?> <label class="radio inline"> <input type="radio" name="time" value="09:00AM TO 10:00AM"> <span>09:00AM TO 10:00AM (Available)</span> </label> <?php } if (!in_array("10:00AM TO 11:00AM", $slots)) { ?> <label class="radio inline"> <input type="radio" name="time" value="10:00AM TO 11:00AM"> <span>10:00AM TO 11:00AM (Available)</span> </label> <?php } if (!in_array("11:00AM TO 12:00PM", $slots)) { ?> <label class="radio inline"> <input type="radio" name="time" value="11:00AM TO 12:00PM"> <span>11:00AM TO 12:00PM (Available)</span> </label> <?php } if (!in_array("12:00PM TO 01:00PM", $slots)) { ?> <label class="radio inline"> <input type="radio" name="time" value="12:00PM TO 01:00PM"> <span>12:00PM TO 01:00PM (Available)</span> </label> <?php } ?> </div> </div> <input type="submit" class="btnRegister" value="Continue"/> </div> </div> </div> </div> </form> </div> </div> </div> </body> Edited March 4, 2020 by Barand Added code tags I have a problem which is why I am here. What I am trying to achieve I am creating a very very basic timetabling system online, using php and sql. I am still in the process of completing it and changing bits from here to there. Although I am fully aware that the current design / implementation needs several changes and amendments, but however it performs most of the basic functionalities from a login system to the ability to add data delete data and also reset the database and recreate. The problem I have a table called tCourse althouogh a full ERD implementation has not taken place, it is still trial and error period. The table consists of the following: - Course - Unit - Course_Code - Year (i.e. Yr1, Yr2, Yr3) - Credits (Value of the unit) - Day - Semester - Start_Time - End_Time - Room - Tutor At the moment the primary keys for the table a - Day - Start_Time - Room_ - Semester This basically prevents a particular day, a semester, a room having been booked at the same time. Which for a very basic one is ok. The only problem is though, if someone books for example: Monday >> 13:00:00 To 14:00:00 >> 205 >> Sem1 (ok) Monday >> 13:00:00 To 14:00:00 >> 205 >> Sem1 (Not ok, which is good, as it is a repeat and prevents double booking) However the problem comes he Monday >> 12:00:00 To 14:00:00 >> 205 >> Sem1 (ok) So this is allowing a booking even though that room will be busy i.e. booked between 13:00 to 14:00 So is there a way I can limit it, so if there is a room booked for that particular period it will not do it. I have done a bit of research and friend's have suggested doind several for loops and quering the database beforehand. I came here, mainly because there are a lot of experienced individuals here whom may have a simpler solution, although I can understand it won't be a one liner . I would appreciate any help, if not, it is still ok.
$sql="SELECT COUNT(*) as conflicts
how do I get the value of the conflicts im now very clueless Hi, I'm a beginner to all this stuff, but I'm redesigning a website that needs an online booking form. I've made the form in HTML and the PHP bit to send direct to an email address. I found the template online. It works fine at sending to the email. But as soon as I started customising it and adding fields for "Date of Arrival" etc it's stopped working. I get a variety of error messages. Could you possibly take a look at it and see what I'm doing wrong? Thanks HTML (booknow.html) <form name="contactform" method="post" action="send_form_email.php"> <table width="450px"> </tr> <tr> <td valign="top"> <label for="first_name">First Name *</label> </td> <td valign="top"> <input type="text" name="first_name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top""> <label for="last_name">Last Name *</label> </td> <td valign="top"> <input type="text" name="last_name" maxlength="50" size="30"> </td> </tr> <tr> <td valign="top"> <label for="email">Email Address *</label> </td> <td valign="top"> <input type="text" name="email" maxlength="80" size="30"> </td> </tr> <tr> <td valign="top"> <label for="telephone">Telephone Number *</label> </td> <td valign="top"> <input type="text" name="telephone" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="arrival">Date of Arrival *</label> </td> <td valign="top"> <input type="text" name="arrival" maxlength="30" size="30"> </td> </tr> <tr> <td valign="top"> <label for="comments">Comments</label> </td> <td valign="top"> <textarea name="comments" maxlength="1000" cols="25" rows="6"></textarea> </td> </tr> <tr> <td colspan="2" style="text-align:center"> <input type="submit" value="Submit"> <a href="http://www.freecontactform.com/email_form.php"></a> </td> </tr> </table> </form> PHP bit (send_form_email.php) <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "MYEMAIL"; $email_subject = "SUBJECT"; function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form you submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['first_name']) || !isset($_POST['last_name']) || !isset($_POST['email']) || !isset($_POST['telephone']) !isset($_POST['arrival']) !isset($_POST['comments'])) { died('We are sorry, but there appears to be a problem with the form you submitted.'); } $first_name = $_POST['first_name']; // required $last_name = $_POST['last_name']; // required $email_from = $_POST['email']; // required $telephone = $_POST['telephone']; // required $telephone = $_POST['arrival']; // required $comments = $_POST['comments']; // not required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } $string_exp = "^[a-z .'-]+$"; if(!eregi($string_exp,$first_name)) { $error_message .= 'The First Name you entered does not appear to be valid.<br />'; } if(!eregi($string_exp,$last_name)) { $error_message .= 'The Last Name you entered does not appear to be valid.<br />'; } if(strlen($telephone) < 2) { $error_message .= 'The Telephone you entered does not appear to be valid.<br />'; } if(strlen($arrival) < 2) { $error_message .= 'The Date of Arrival you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "First Name: ".clean_string($first_name)."\n"; $email_message .= "Last Name: ".clean_string($last_name)."\n"; $email_message .= "Email: ".clean_string($email_from)."\n"; $email_message .= "Telephone: ".clean_string($telephone)."\n"; $email_message .= "Date of Arrival: ".clean_string($arrival)."\n"; $email_message .= "Comments: ".clean_string($comments)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for contacting us. We will be in touch with you soon. <? } ?> I think something's wrong with the way I added Date of Arrival, but I don't know what. Thanks in advance for any advice |