Good day!
I created a webpages and i have a login page consist of Username and Department. And i encountered problem in adding event in my calendar.
This is the flow of my webpage:
First I have a separate table for the user and calendar. In my user table it has a Username, Department, and Permission. In the permission I put True or False, only one user i put True because i want that user is the one who permitted to add event or if she is login the add event link appear, but if other login the add even0t did not appear.
This is my code in login:
[php]
[/php]
and this is my code in calendar page:
[php]
<?php session_start(); $host = "localhost"; $username = ""; $password = ""; $dbCnx = @mysql_connect($host, $username, $password) or die('Could not Connect to the database'); $dbName = 'dspi'; mysql_select_db($dbName); ?> <?php //$todaysDate = date("n/j/Y"); //echo $todaysDate; // Get values from query string $day = (isset($_GET["day"])) ? $_GET['day'] : ""; $month = (isset($_GET["month"])) ? $_GET['month'] : ""; $year = (isset($_GET["year"])) ? $_GET['year'] : ""; //comparaters for today's date //$todaysDate = date("n/j/Y"); //$sel = (isset($_GET["sel"])) ? $_GET['sel'] : ""; //$what = (isset($_GET["what"])) ? $_GET['what'] : ""; //$day = (!isset($day)) ? $day = date("j") : $day = ""; if(empty($day)){ $day = date("j"); } if(empty($month)){ $month = date("n"); } if(empty($year)){ $year = date("Y"); } //set up vars for calendar etc $currentTimeStamp = strtotime("$year-$month-$day"); $monthName = date("F", $currentTimeStamp); $numDays = date("t", $currentTimeStamp); $counter = 0; //$numEventsThisMonth = 0; //$hasEvent = false; //$todaysEvents = ""; //run a selec statement to hi-light the days function hiLightEvt($eMonth,$eDay,$eYear){ //$tDayName = date("l"); $todaysDate = date("n/j/Y"); $dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; if($todaysDate == $dateToCompare){ //$aClass = '' . $tDayName . ''; $aClass='class="today"'; }else{ //$dateToCompare = $eMonth . '/' . $eDay . '/' . $eYear; //echo $todaysDate; //return; $sql="select count(calDate) as eCount from calTbl where calDate = '" . $eMonth . '/' . $eDay . '/' . $eYear . "'"; //echo $sql; //return; $result = mysql_query($sql); while($row= mysql_fetch_array($result)){ if($row['eCount'] >=1){ $aClass = 'class="event"'; }elseif($row['eCount'] ==0){ $aClass ='class="normal"'; } } } return $aClass; } ?>);"> |
<?php echo $monthName . " " . $year; ?> |
);"> | ||||
M | T | W | T | F | S | S |
---|---|---|---|---|---|---|
"; } } if($counter % 7 == 0 ){ ?> | ||||||
><?=$i;?> | <?php } ?>
$check=mysql_query(“SELECT * FROM tbllogin WHERE Username=‘xxx’ AND Department=‘HRAD’ AND Permission=‘True’”);
mysql_fetch_array($check);
if($check[‘Username’]==‘xxx’ && $check[‘Department’]==‘HRAD’){
$_SESSION[‘isallowed’] = $check[‘Permission’];
//if (mysql_num_rows($check)>0){
?>
Add Event<?php
}else{
echo ‘You cannot Add New Event’;
}?>
- ';
echo '
Event Listed
'; while($row = mysql_fetch_array($result)){ ?><?=$row['calName'];?>
<?=$row['calDesc'];?>Listed On: <?=$row['calStamp'];?> <?php } } } ?>
In that code when the user log is xxx and when she click a date she want to add event the appear is “You cannot Add Event”.
I hope somebody can help me…
Thank you in advance…