Foxeh
29-07-2006, 05:32 PM
Hi, i have a working timetable script but i've encountered errors whilst trying to develop an script which allows DJs to select a date and time and if the booked DJ's name matches their logged in account name the show deletes. Unfortunately it won't work and i was wondering if any1 could help.
* The config file location and connection coding and information is correct.
* The $logged and $POST parts retrive the information as i received it back in one error.
* The table fields are correct.
Bearing in mind that info, can any1 spot any errors in this coding and paste the correct one, thanks.
-------------------------------------
File name: delete_slot.php
-------------------------------------
<html>
<head>
</head>
<body bgcolor="#47839D">
<CENTER>
<center><strong><font size="3" face="verdana" color="white"><u>Delete A Slot</u></Font></strong>
<?php
ob_start();
include("../config.php");
if($logged['username']);
{
if(!$_POST['posttime']) //have they submitted the form?
{
$date = date("m-y"); // the current date (only months and years)
echo "
<form onsubmit='return checkValues()' name='book' method='post'>
<p><strong><font size=\"1\" face=\"verdana\" color=\"white\">DJ Name:</strong><br>
DJ $logged[username] <br>
</p>
<p><strong>Date: *</strong>
<select name='date' id='date'>
<option value=\"select\">--- Please Select ---</option>
<option>1-$date</option>
<option>2-$date</option>
<option>3-$date</option>
<option>4-$date</option>
<option>5-$date</option>
<option>6-$date</option>
<option>7-$date</option>
<option>8-$date</option>
<option>9-$date</option>
<option>10-$date</option>
<option>11-$date</option>
<option>12-$date</option>
<option>13-$date</option>
<option>14-$date</option>
<option>15-$date</option>
<option>16-$date</option>
<option>17-$date</option>
<option>18-$date</option>
<option>19-$date</option>
<option>20-$date</option>
<option>21-$date</option>
<option>22-$date</option>
<option>23-$date</option>
<option>24-$date</option>
<option>25-$date</option>
<option>26-$date</option>
<option>27-$date</option>
<option>28-$date</option>
<option>29-$date</option>
<option>30-$date</option>
<option>31-$date</option>
</select>
<br><br>
<strong>Time: *</strong>
<select name='time' id='time'>
<option value=\"select\">--- Please Select ---</option>
<option>12:00am</option>
<option>1:00am</option>
<option>2:00am</option>
<option>3:00am</option>
<option>4:00am</option>
<option>5:00am</option>
<option>6:00am</option>
<option>7:00am</option>
<option>8:00am</option>
<option>9:00am</option>
<option>10:00am</option>
<option>11:00am</option>
<option>12:00pm</option>
<option>1:00pm</option>
<option>2:00pm</option>
<option>3:00pm</option>
<option>4:00pm</option>
<option>5:00pm</option>
<option>6:00pm</option>
<option>7:00pm</option>
<option>8:00pm</option>
<option>9:00pm</option>
<option>10:00pm</option>
<option>11:00pm</option>
</select>
<br>
<br>
<br>
<input type='submit' name='posttime' value='Delete Slot'>
</p>
</form>
<script language=\"JavaScript\">
function checkValues() {
if (document.book.date.value==\"select\") {
alert(\"Please select a date!\");
document.book.date.focus();
return false; }
if (document.book.time.value==\"select\") {
alert(\"Please select a time!\");
document.book.time.focus();
return false; }
document.book.submit(); }
</script>
* Required
"; // the form its pretty easy to understand that bit
}
if ($_POST['posttime']) // have they posted the form?
{
$get = mysql_query("SELECT * FROM timetable");
mysql_fetch_array("$get");
$dj = $get['dj'];
if ($logged['username'] == "$dj");
{
$time = $_POST['time'];
$date = $_POST['date'];
$username = $logged['username'];
mysql_query("DELETE * FROM timetable WHERE date = '$date', time = '$time' and dj = '$username'")
or die('MySQL said: ' . mysql_error());
echo "<br><br>Thank You, your slot has been deleted"; //
}
}
else {
echo"This is not your show to delete!";
}
}
?>
* The config file location and connection coding and information is correct.
* The $logged and $POST parts retrive the information as i received it back in one error.
* The table fields are correct.
Bearing in mind that info, can any1 spot any errors in this coding and paste the correct one, thanks.
-------------------------------------
File name: delete_slot.php
-------------------------------------
<html>
<head>
</head>
<body bgcolor="#47839D">
<CENTER>
<center><strong><font size="3" face="verdana" color="white"><u>Delete A Slot</u></Font></strong>
<?php
ob_start();
include("../config.php");
if($logged['username']);
{
if(!$_POST['posttime']) //have they submitted the form?
{
$date = date("m-y"); // the current date (only months and years)
echo "
<form onsubmit='return checkValues()' name='book' method='post'>
<p><strong><font size=\"1\" face=\"verdana\" color=\"white\">DJ Name:</strong><br>
DJ $logged[username] <br>
</p>
<p><strong>Date: *</strong>
<select name='date' id='date'>
<option value=\"select\">--- Please Select ---</option>
<option>1-$date</option>
<option>2-$date</option>
<option>3-$date</option>
<option>4-$date</option>
<option>5-$date</option>
<option>6-$date</option>
<option>7-$date</option>
<option>8-$date</option>
<option>9-$date</option>
<option>10-$date</option>
<option>11-$date</option>
<option>12-$date</option>
<option>13-$date</option>
<option>14-$date</option>
<option>15-$date</option>
<option>16-$date</option>
<option>17-$date</option>
<option>18-$date</option>
<option>19-$date</option>
<option>20-$date</option>
<option>21-$date</option>
<option>22-$date</option>
<option>23-$date</option>
<option>24-$date</option>
<option>25-$date</option>
<option>26-$date</option>
<option>27-$date</option>
<option>28-$date</option>
<option>29-$date</option>
<option>30-$date</option>
<option>31-$date</option>
</select>
<br><br>
<strong>Time: *</strong>
<select name='time' id='time'>
<option value=\"select\">--- Please Select ---</option>
<option>12:00am</option>
<option>1:00am</option>
<option>2:00am</option>
<option>3:00am</option>
<option>4:00am</option>
<option>5:00am</option>
<option>6:00am</option>
<option>7:00am</option>
<option>8:00am</option>
<option>9:00am</option>
<option>10:00am</option>
<option>11:00am</option>
<option>12:00pm</option>
<option>1:00pm</option>
<option>2:00pm</option>
<option>3:00pm</option>
<option>4:00pm</option>
<option>5:00pm</option>
<option>6:00pm</option>
<option>7:00pm</option>
<option>8:00pm</option>
<option>9:00pm</option>
<option>10:00pm</option>
<option>11:00pm</option>
</select>
<br>
<br>
<br>
<input type='submit' name='posttime' value='Delete Slot'>
</p>
</form>
<script language=\"JavaScript\">
function checkValues() {
if (document.book.date.value==\"select\") {
alert(\"Please select a date!\");
document.book.date.focus();
return false; }
if (document.book.time.value==\"select\") {
alert(\"Please select a time!\");
document.book.time.focus();
return false; }
document.book.submit(); }
</script>
* Required
"; // the form its pretty easy to understand that bit
}
if ($_POST['posttime']) // have they posted the form?
{
$get = mysql_query("SELECT * FROM timetable");
mysql_fetch_array("$get");
$dj = $get['dj'];
if ($logged['username'] == "$dj");
{
$time = $_POST['time'];
$date = $_POST['date'];
$username = $logged['username'];
mysql_query("DELETE * FROM timetable WHERE date = '$date', time = '$time' and dj = '$username'")
or die('MySQL said: ' . mysql_error());
echo "<br><br>Thank You, your slot has been deleted"; //
}
}
else {
echo"This is not your show to delete!";
}
}
?>