PHP Code:
function CheckForDJ() {
require('config.php');
if (preg_match('/^(\d{2})-(\d{2})-(\d{2})$/', $_REQUEST['txtDate'], $datebit)) {
$checkthisdate = checkdate ($datebit[2], $datebit[1], $datebit[3]);
echo ValidateDate($checkthisdate);
} else {
echo "$invalidateformatmsg";
}
}
function ValidateDate($datetovalidate){;
require('config.php');
if($datetovalidate == "bool(true)"){
requestDate();
}else {
echo "$invaliddatemsg"; return false;
}
}
function requestDate()
{
require('config.php');
$list = explode("\r\n",file_get_contents("$dbname"));
if (array_search($_REQUEST["txtDate"], $list) === FALSE) {
$list[] = $_REQUEST["txtDate"];
$new = implode ("\r\n",$list);
echo "$bookingavailable";
} else {echo "$bookingnotavailable";}
}
?>
CheckForDJ();
thetestingsite wondering if you could do me a fav and the above code put it into 1 function ? with 2 parametres 1 for date and the other for dj name so be like
CheckForDj($date,$djname);
so that input would first check the input of the textfield (wich will be the date) if the format is in valid format, DD/MM/YY, if it isnt then echo error sumthing like 'invalid date format' if the format is correct then it will go on to check if the date is valid if the date is invalid then echo error 'invalid date' if both of them pass then it will check against a text file the date entered and the dj name for example CheckForDj(this bit will be requested from the textfield the date,'Peter'); so if the date EXISTS in the text file then echo 'not available' if it is NOT in the text file then echo available, i have done that bit but i would require it in 1 function rather than 3 with the params above, if you do it as described i will give u $10 thru paypal (if u got) as a little thank you
this shouldnt be much work at all considering the code is almost complete a few things need changeing is the date format, i would like it to be DD/MM/YY rather than the current DD-MM-YY, also for example if there are 3 djs and all three are avilable should say something like dj1, dj2 and dj3 are available if there is 4 it would say dj1, dj1, dj3 and dj3 are available however is there is only 2 it will say dj1 and dj2 are available and in the text file it will say DD/MM/YY dj1, dj2 so them 2 dj's are not avilable but the 3rd is,
look forward to your reply hope you can help, thaks so much
Bookmarks