Ok So I got it to Insert the data in the table but im havin a problem I want to check if the user entered something other than 00 or 30 for their appointment time but right now It isnt working it just gets to the if statement which evaluates as true for everything I enter
<?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;
}
}
}
?>
Reputation Points: 33
Solved Threads: 19
Nearly a Posting Virtuoso
Offline 1,496 posts
since May 2004