Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,925 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,825 people online right now. Registration is fast and FREE... Join Now!




Search File to see if appointment already exists for 30 min intervals

 
Reply to this topicStart new topic

Search File to see if appointment already exists for 30 min intervals, for an online client appointment calendar

inf4my
14 Mar, 2008 - 08:47 AM
Post #1

New D.I.C Head
*

Joined: 19 Nov, 2007
Posts: 23


My Contributions
Ok So right now I am using a script called MicroCalendar to setup a client calendar where A client can add an appointment to it but I need to put something into place that makes sure that they cannot overlap appointments..right Now im just saving appointments to txt files with the date of the appointment on them..here is my current code, i have not tried to check the half hour interval yet..

CODE

       <?php    
        $myFile = "appointment $_POST[day]-$_POST[month]-$_POST[year].txt";
        $fh = fopen($myFile, 'w');
        fclose($fh);
        $fh1 = fopen($myfile, 'a');
        if($_POST[ok])
        {
         $stringData = "$_POST[name], scheduled an appointment at $_POST[hour]:$_POST[minute] on $_POST[day]-$_POST[month]-$_POST[year]";
         $handle = @fopen($file, 'r');
         $contents = @fread($handle, filesize($file));
         $strPos = strpos( $stringdata , $contents);
         if ($strPos!== false)
         {
             fwrite($fh, $stringData);
             fclose($fh);
             echo "<br>$_POST[name], scheduled an appointment at $_POST[hour]:$_POST[minute] on $_POST[day]-$_POST[month]-$_POST[year]";  
         }
       ?>


User is offlineProfile CardPM
+Quote Post

ahmad_511
RE: Search File To See If Appointment Already Exists For 30 Min Intervals
14 Mar, 2008 - 07:42 PM
Post #2

D.I.C Regular
Group Icon

Joined: 28 Apr, 2007
Posts: 351



Thanked: 8 times
Dream Kudos: 400
My Contributions
Hello
1- you're not catching right the posted variables this way,you have to quote the var name,so fix it to become like this:
php

$_POST['day']


2- you're opening the file and close it right away, so that's doesn't make sense. and i think you don't need this part
QUOTE

$fh = fopen($myFile, 'w');
fclose($fh);


3- variable's names are case sensitive in php, so replace $myfile with $myFile
QUOTE

$fh1 = fopen($myfile, 'a');


4- what is $file here ,you didn't define it.
QUOTE

$handle = @fopen($file, 'r');


5- you write to the wrong file handler $fh is already closed,so you may need to change it to $fh1
QUOTE

fwrite($fh, $stringData);
fclose($fh);


Well after all I think that code will not give you what you want
I'm in rush now maybe i can take a look at it later or some other members can help you fix the code
Good Luck
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:20PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month