Right now I have some code that takes input from a calendar and adds into a database and checks if the info is already in there for that time slot..but I want to set it up so that you can only make the time '00' or '30' so its in 30 min intervals, but the check isnt working..here is my current code.
CODE
<?php
$host="localhost"; // Host name
$username="root"; // Mysql username
$password="original"; // Mysql password
$db_name="cutting_edge"; // Database name
$tbl_name="appoint"; // Table name
// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
if($_POST[ok])
{
$date = "$_POST[month]-$_POST[day]-$_POST[year]";
$name = $_POST['name'];
$time = "$_POST[hour]:$_POST[minute]";
$min = $_POST['minute'];
if(($min != '00') || ($min != '30')){
echo "Appointments are every 30 minutes please re-choose your time to accommodate this schedule";
echo $min;
}
else{
// To protect MySQL injection (more detail about MySQL injection)
$date = stripslashes($date);
$name = stripslashes($name);
$date = mysql_real_escape_string($date);
$name = mysql_real_escape_string($name);
$time = stripslashes($time);
$time = mysql_real_escape_string($time);
$sql="SELECT * FROM $tbl_name WHERE date='$date' and time='$time'";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
if( $count == 0){
$sql ="INSERT INTO appoint VALUES( '$date', '$time', '$name' )";
mysql_query($sql);
echo "$name, Scheduled an appointment for $time on $date";
}
else{
echo "An Appointment Is already Scheduled for this time ";
echo $time;
}
}
}
?>