PDA

View Full Version : Coding Help



Lilian
16-12-2006, 07:07 PM
Im having trouble with this timetable its not booking when you click "Book slot" can anyone help? heres the code:


<?php
ob_start(); # Allows Cookies
include("config.php"); # Includes Your Configuration File
include("funcs.php");
if($logged[username] && $logged[level] == 11 OR $logged[level] == 12) # If Logged In AND Level 5
{
if($_GET["action"] == "book")
{
$day = $_GET["date"];
$time = $_GET["slot"];

$worked = mysql_fetch_array(mysql_query("SELECT `$time` FROM `timetable` WHERE `day`='$day'"));
if($worked[$time] != "")
{
header("Location: ?date=$day");
}
else
{
mysql_query("UPDATE `timetable` SET `$time`='{$logged[username]}' WHERE `day`='$day'");
}
header("Location: ?date=$day");
}
elseif($_GET["action"] == "unbook")
{
$day = $_GET["date"];
$time = $_GET["slot"];
$worked = mysql_fetch_array(mysql_query("SELECT `$time` FROM `timetable` WHERE `day`='$day'"));
$split = explode(";", $worked[$time]);
if($split[0] == "Enumeric" and $logged[username] != "Enumeric")
{
header("Location: $PHP_SELF?day=$day");
}
if($split[0] == $logged[username] or $logged[level] == "12")
{
mysql_query("UPDATE `timetable` SET `$time`='' WHERE `day`='$day'");
}
header("Location: $PHP_SELF?date=$day");
}
elseif($_GET["action"] == "clear")
{
$day = anti_hack($_GET["date"]);
mysql_query("UPDATE `timetable` SET `1`='', `2`='', `3`='', `4`='', `5`='', `6`='', `7`='', `8`='', `9`='', `10`='', `11`='', `12`='', `13`='', `14`='', `15`='', `16`='', `17`='', `18`='', `19`='', `20`='', `21`='', `22`='', `23`='', `24`='' WHERE `day`='$day'");
header("Location: $PHP_SELF?date=$_GET[date]");
}
else
{
if($_GET["date"] == "")
{
$day = date("l");
}
else
{
$day = anti_hack($_GET["date"]);
}
$time = mysql_fetch_array(mysql_query("SELECT * FROM `timetable` WHERE `day` = '$day'"));
if($time["1"] == "")
{ $one = "<a href=\"?action=book&date=$day&slot=1\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["1"] or $time["1"] != "" and $logged[level] == "12")
{ $one = "<a href=\"?action=unbook&date=$day&slot=1\">{$time["1"]} (Unbook)</a>"; }
else
{ $one = "{$time["1"]}"; }

if($time["2"] == "")
{ $two = "<a href=\"?action=book&date=$day&slot=2\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["2"] or $time["2"] != "" and $logged[level] == "12")
{ $two = "<a href=\"?action=unbook&date=$day&slot=2\">{$time["2"]} (Unbook)</a>"; }
else
{ $two = "{$time["2"]}"; }

if($time["3"] == "")
{ $three = "<a href=\"?action=book&date=$day&slot=3\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["3"] or $time["3"] != "" and $logged[level] == "12")
{ $three = "<a href=\"?action=unbook&date=$day&slot=3\">{$time["3"]} (Unbook)</a>"; }
else
{ $three = "{$time["3"]}"; }

if($time["4"] == "")
{ $four = "<a href=\"?action=book&date=$day&slot=4\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["4"] or $time["4"] != "" and $logged[level] == "12")
{ $four = "<a href=\"?action=unbook&date=$day&slot=4\">{$time["4"]} (Unbook)</a>"; }
else
{ $four = "{$time["4"]}"; }

if($time["5"] == "")
{ $five = "<a href=\"?action=book&date=$day&slot=5\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["5"] or $time["5"] != "" and $logged[level] == "12")
{ $five = "<a href=\"?action=unbook&date=$day&slot=5\">{$time["5"]} (Unbook)</a>"; }
else
{ $five = "{$time["5"]}"; }

if($time["6"] == "")
{ $six = "<a href=\"?action=book&date=$day&slot=6\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["6"] or $time["6"] != "" and $logged[level] == "12")
{ $six = "<a href=\"?action=unbook&date=$day&slot=6\">{$time["6"]} (Unbook)</a>"; }
else
{ $six = "{$time["6"]}"; }

if($time["7"] == "")
{ $seven = "<a href=\"?action=book&date=$day&slot=7\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["7"] or $time["7"] != "" and $logged[level] == "12")
{ $seven = "<a href=\"?action=unbook&date=$day&slot=7\">{$time["7"]} (Unbook)</a>"; }
else
{ $seven = "{$time["7"]}"; }

if($time["8"] == "")
{ $eight = "<a href=\"?action=book&date=$day&slot=8\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["8"] or $time["8"] != "" and $logged[level] == "12")
{ $eight = "<a href=\"?action=unbook&date=$day&slot=8\">{$time["8"]} (Unbook)</a>"; }
else
{ $eight = "{$time["8"]}"; }

if($time["9"] == "")
{ $nine = "<a href=\"?action=book&date=$day&slot=9\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["9"] or $time["9"] != "" and $logged[level] == "12")
{ $nine = "<a href=\"?action=unbook&date=$day&slot=9\">{$time["9"]} (Unbook)</a>"; }
else
{ $nine = "{$time["9"]}"; }

if($time["10"] == "")
{ $ten = "<a href=\"?action=book&date=$day&slot=10\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["10"] or $time["10"] != "" and $logged[level] == "12")
{ $ten = "<a href=\"?action=unbook&date=$day&slot=10\">{$time["10"]} (Unbook)</a>"; }
else
{ $ten = "{$time["10"]}"; }

if($time["11"] == "")
{ $eleven = "<a href=\"?action=book&date=$day&slot=11\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["11"] or $time["11"] != "" and $logged[level] == "12")
{ $eleven = "<a href=\"?action=unbook&date=$day&slot=11\">{$time["11"]} (Unbook)</a>"; }
else
{ $eleven = "{$time["11"]}"; }

if($time["12"] == "")
{ $twelve = "<a href=\"?action=book&date=$day&slot=12\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["12"] or $time["12"] != "" and $logged[level] == "12")
{ $twelve = "<a href=\"?action=unbook&date=$day&slot=12\">{$time["12"]} (Unbook)</a>"; }
else
{ $twelve = "{$time["12"]}"; }

if($time["13"] == "")
{ $thirteen = "<a href=\"?action=book&date=$day&slot=13\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["13"] or $time["13"] != "" and $logged[level] == "12")
{ $thirteen = "<a href=\"?action=unbook&date=$day&slot=13\">{$time["13"]} (Unbook)</a>"; }
else
{ $thirteen = "{$time["13"]}"; }

if($time["14"] == "")
{ $fourteen = "<a href=\"?action=book&date=$day&slot=14\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["14"] or $time["14"] != "" and $logged[level] == "12")
{ $fourteen = "<a href=\"?action=unbook&date=$day&slot=14\">{$time["14"]} (Unbook)</a>"; }
else
{ $fourteen = "{$time["14"]}"; }

if($time["15"] == "")
{ $fifteen = "<a href=\"?action=book&date=$day&slot=15\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["15"] or $time["15"] != "" and $logged[level] == "12")
{ $fifteen = "<a href=\"?action=unbook&date=$day&slot=15\">{$time["15"]} (Unbook)</a>"; }
else
{ $fifteen = "{$time["15"]}"; }

if($time["16"] == "")
{ $sixteen = "<a href=\"?action=book&date=$day&slot=16\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["16"] or $time["16"] != "" and $logged[level] == "12")
{ $sixteen = "<a href=\"?action=unbook&date=$day&slot=16\">{$time["16"]} (Unbook)</a>"; }
else
{ $sixteen = "{$time["16"]}"; }

if($time["17"] == "")
{ $seventeen = "<a href=\"?action=book&date=$day&slot=17\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["17"] or $time["17"] != "" and $logged[level] == "12")
{ $seventeen = "<a href=\"?action=unbook&date=$day&slot=17\">{$time["17"]} (Unbook)</a>"; }
else
{ $seventeen = "{$time["17"]}"; }

if($time["18"] == "")
{ $eighteen = "<a href=\"?action=book&date=$day&slot=18\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["18"] or $time["18"] != "" and $logged[level] == "12")
{ $eighteen = "<a href=\"?action=unbook&date=$day&slot=18\">{$time["18"]} (Unbook)</a>"; }
else
{ $eighteen = "{$time["18"]}"; }

if($time["19"] == "")
{ $nineteen = "<a href=\"?action=book&date=$day&slot=19\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["19"] or $time["19"] != "" and $logged[level] == "12")
{ $nineteen = "<a href=\"?action=unbook&date=$day&slot=19\">{$time["19"]} (Unbook)</a>"; }
else
{ $nineteen = "{$time["19"]}"; }

if($time["20"] == "")
{ $twenty = "<a href=\"?action=book&date=$day&slot=20\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["20"] or $time["20"] != "" and $logged[level] == "12")
{ $twenty = "<a href=\"?action=unbook&date=$day&slot=20\">{$time["20"]} (Unbook)</a>"; }
else
{ $twenty = "{$time["20"]}"; }
if($time["21"] == "")
{ $twentyone = "<a href=\"?action=book&date=$day&slot=21\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["21"] or $time["21"] != "" and $logged[level] == "12")
{ $twentyone = "<a href=\"?action=unbook&date=$day&slot=21\">{$time["21"]} (Unbook)</a>"; }
else
{ $twentyone = "{$time["21"]}"; }

if($time["22"] == "")
{ $twentytwo = "<a href=\"?action=book&date=$day&slot=22\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["22"] or $time["22"] != "" and $logged[level] == "12")
{ $twentytwo = "<a href=\"?action=unbook&date=$day&slot=22\">{$time["22"]} (Unbook)</a>"; }
else
{ $twentytwo = "{$time["22"]}"; }

if($time["23"] == "")
{ $twentythree = "<a href=\"?action=book&date=$day&slot=23\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["23"] or $time["23"] != "" and $logged[level] == "12")
{ $twentythree = "<a href=\"?action=unbook&date=$day&slot=23\">{$time["23"]} (Unbook)</a>"; }
else
{ $twentythree = "{$time["23"]}"; }

if($time["24"] == "")
{ $twentyfour = "<a href=\"?action=book&date=$day&slot=24\">BOOK THIS SLOT</a>"; }
elseif($logged[username] == $time["24"] or $time["24"] != "" and $logged[level] == "12")
{ $twentyfour = "<a href=\"?action=unbook&date=$day&slot=24\">{$time["24"]} (Unbook)</a>"; }
else
{ $twentyfour = "{$time["24"]}"; }
echo "
<link href=\"content.css\" rel=\"stylesheet\" type=\"text/css\">
<span class=\"title\">The Timetable</span><br>
<span class=\"desc\">BOOK now to avoid disappointment!</span><br><br>
You are currently viewing ";
if($_GET["date"] == "")
{
$day = date("l");
}
else
{
$day = anti_hack($_GET["date"]);
}
echo "$day";
echo"<br>Book your slots now ;o<br><br>
<hr align=\"left\" size=\"1\">
<center>
<a href=\"?date=Monday\">Monday</a> | <a href=\"?date=Tuesday\">Tuesday</a> | <a href=\"?date=Wednesday\">Wednesday</a> | <a href=\"?date=Thursday\">Thursday</a> | <a href=\"?date=Friday\">Friday</a> | <a href=\"?date=Saturday\">Saturday</a> | <a href=\"?date=Sunday\">Sunday</a> |
</center>
<hr align=\"left\" size=\"1\">
<div align=\"center\">
<table border=\"0\">
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">Time</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">Moderator Booked</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">00:01 - 01:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$one</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">01:01 - 02:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$two</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">02:01 - 03:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$three</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">03:01 - 04:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$four</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">04:01 - 05:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$five</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">05:01 - 06:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$six</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">06:01 - 07:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$seven</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">07:01 - 08:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$eight</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">08:01 - 09:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$nine</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">09:01 - 10:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$ten</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">10:01 - 11:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$eleven</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">11:01 - 12:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$twelve</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">12:01 - 13:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$thirteen</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">13:01 - 14:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$fourteen</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">14:01 - 15:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$fifteen</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">15:01 - 16:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$sixteen</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">16:01 - 17:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$seventeen</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">17:01 - 18:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$eighteen</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">18:01 - 19:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$nineteen</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">19:01 - 20:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$twenty</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">20:01 - 21:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$twentyone</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">21:01 - 22:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$twentytwo</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">22:01 - 23:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$twentythree</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">23:01 - 00:00</td>
<td height=\"9\" width=\"150\">
<p align=\"center\">$twentyfour</td>
</tr>
<tr>
<td height=\"9\" width=\"150\">
<p align=\"center\">$day</td>
<td height=\"9\" width=\"150\">
";?> <?php if ($logged[level] == "12")
{ echo("<p align=\"center\"><a href=\"?action=clear&date=$day\">CLEAR TODAY</a>");} ?> <?php echo("</td>
</tr>
</table>
</div>
");
}
} else { # User Isn't Logged In Or Level 5
echo("You Are Not Logged In Or Level 5"); # Shows Message
}
?>

+REP To people who help. Thanks

CJ-real
16-12-2006, 08:28 PM
Maybe you could try a different timetable... how about I create a simple, yet effective one for you? It will be a form which edits a "notepad" file... then you use the php "include"/"injection" to have a timetable going...

Do you want me to do this?

Lilian
16-12-2006, 08:38 PM
Yes please, if anyone ealse could also try fixing that one above would be grt ;)

CJ-real
16-12-2006, 08:39 PM
OK, then you won't be needing me for the minute :P

xRoyal15
16-12-2006, 08:42 PM
to be honest.. nothing looks wrong with it :S

tekni
16-12-2006, 08:44 PM
to be honest.. nothing looks wrong with it :S
but then again, nothing is wrong with your user system...:rolleyes:

Lilian
16-12-2006, 08:49 PM
to be honest.. nothing looks wrong with it :S

Something is wrong with it otherwise i wouldnt be posting the proberly. It doesnt book slots when u click "Book Slot" :)


but then again, nothing is wrong with your user system...:rolleyes:

Lol

CJ-real
16-12-2006, 08:50 PM
That means that the POST action doesn't work

Lilian
16-12-2006, 08:52 PM
How could i fix it?

xRoyal15
16-12-2006, 08:53 PM
That means that the POST action doesn't work
It doesnt use the POST action



but then again, nothing is wrong with your user system...:rolleyes:


That page of the usersystem wasnt coded by me ;) it was coded by Dentafrice haha owned

CJ-real
16-12-2006, 08:53 PM
No, not the actual POST action, yet the "edit" or the thing that changes the sql...

xRoyal15
16-12-2006, 09:01 PM
The only thing i can think of is possibly an error with the func.php file you have included.

Post the code for that and ill have a look :)

Lilian
16-12-2006, 09:06 PM
<?php
ob_start();
function anti_hack($value)
{
if(get_magic_quotes_gpc()) {
$value = stripslashes($value);
}

if(!is_numeric($value)) {
$value = mysql_real_escape_string($value);
}
return $value;
}
function login()
{
if(!isset($_SESSION["session_username"]) || empty($_SESSION["session_username"]) || $_SERVER["REMOTE_ADDR"] != $_SESSION["session_ip"])
{
session_unset();
session_destroy();
die("Umm.. gotta login there mate");
}
}
function generateRandStr($length)
{
$randstr = "";
for($i=0; $i<$length; $i++)
{
$randnum = mt_rand(0,61);
if($randnum < 10)
{
$randstr .= chr($randnum+48);
}
else if($randnum < 36)
{
$randstr .= chr($randnum+55);
}
else
{
$randstr .= chr($randnum+61);
}
}
return $randstr;
}
?>

Dentafrice1
24-12-2006, 09:05 PM
Thats the problem I do believe. Hmmm.. ill take a look at it.

its trying to use $_SESSION[session_username] When his usersystem uses cookies.

I built this for my DJ panel so I did not convert it over to cookies for his.

Ill post a fixed version later today .

Be happy.. im doing this on christmas eve :P

Lilian
26-12-2006, 01:48 PM
I think i found the error now anyways. Thanks for pointing that out ;) Sure i can fix it:)

YouFail
26-12-2006, 01:56 PM
I didn't look properly at the code but it seems that your trying to set the time as the session name. Its not the problem but it still is a problem. Forgive me if im wrong though.

Lilian
26-12-2006, 01:57 PM
Its ok im sure i can fix it now, Thank you for all your help :)

Want to hide these adverts? Register an account for free!