10 Replies - 1630 Views - Last Post: 03 September 2010 - 03:58 PM Rate Topic: -----

#1 Guest_newbees*


Reputation:

Adding Events in Calendar

Posted 22 August 2010 - 08:41 PM

Good day!

i want to share my problem in my website

For the better understandng of my website, I want to tell all the details.

1. I have a database and i has a 2 tables 1 for the tbllogin which consist of Username and Department, and the second table is caltbl which i use for the calendar events.

2.When my website run the first webpage is the login form. If the Username and Department is correct she can browse the other webpages, like the calendar event.


3. In the calendar event you can see the calendar and when you click the date theirs a link "new event" appear and if theirs no existing event theres a text saying "No Events", when you click the link you can add events. I want that theirs a specific person that can only add events for the restriction of adding events. I want to happen that if the user is xxx and her department is yyy the link shoud appear and she can add events. i want that only to her the liknk should be visible or unhide..

here is the code on my calendar in that code i hide the layer where the link shoud appear:

<?php
$host = "localhost";

	$username = "";

	$password = "";

	$dbCnx = @mysql_connect($host, $username, $password) or die('Could not Connect to the database');

	$dbName = 'dspi';

	mysql_select_db($dbName);	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DSPI CALENDAR EVENTS</title>
<script>
function goLastMonth(month, year){
// If the month is January, decrement the year
if(month == 1){
--year;
month = 13;
}
document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year;
}
//next function
function goNextMonth(month, year){
// If the month is December, increment the year
if(month == 12){
++year;
month = 0;
}
document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year;
} 

function remChars(txtControl, txtCount, intMaxLength)
{
if(txtControl.value.length > intMaxLength)
txtControl.value = txtControl.value.substring(0, (intMaxLength-1));
else
txtCount.value = intMaxLength - txtControl.value.length;
}

function checkFilled() {
var filled = 0
var x = document.form1.calName.value;
//x = x.replace(/^\s+/,""); // strip leading spaces
if (x.length > 0) {filled ++}

var y = document.form1.calDesc.value;
//y = y.replace(/^s+/,""); // strip leading spaces
if (y.length > 0) {filled ++}

if (filled == 2) {
document.getElementById("Submit").disabled = false;
}
else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased

}

</script>
<style>
body{
background-image: url(layout_image/bgroundv09.png);
background-attachment: fixed; 
font-family:Georgia, "Times New Roman", Times, serif;
font-size:16px;
}
.today{
/*background-color:#00CCCC;*/
font-weight:bold;
font-style:italic;
border-bottom-style:dashed;
background-image:url(calBg.jpg);
background-repeat:no-repeat;
background-position:center;
position:relative;
color:#FFFF00;
}
.today span{
position:absolute;
left:0;
top:0; 
}

.today a{
color:#FFFF00;
padding-top:10px;
}
.selected {
color: #FFFFFF;
background-color: #C00000;
}
.event {
/*background-color: #C6D1DC;*/
/*border:1px solid #ffffff;*/
background-image:url(layout_image/boxv01.png);
border: 1px ;
/*border-bottom-style:dashed;*/
/*border color #427e1a;*/
} 
.normal {

} 
table{
border:1px solid #cccccc;
padding:3px;
}
th{
width:36px;
background-color:#bcdd24;
text-align:center;
color:#ffffff;
border-left:1px solid #ffffff;
}
td{
text-align:center;
padding:8px;
margin:0;
}
table.tableClass{
width:350px;
border:none;
border-collapse: collapse;
font-size:85%;
border:1px dotted #cccccc;
}
table.tableClass input,textarea{
font-size:90%;
}
#form1{
margin:5px 0 0 0;
}
#greyBox{
height:10px;
width:10px;
background-color:#C6D1DC;
border:1px solid #666666;
margin:5px;
}
#hr{border-bottom:1px solid #cccccc;width:300px;}
.output{width:300px;border-bottom:1px dotted #ccc;margin-bottom:5px;padding:6px;}
h5{margin:0;}

</style>
<style type="text/css">
#Calendar_Event {
	position:absolute;
	width:200px;
	height:101px;
	z-index:2;
	left: 255px;
	top: 233px;
}
#New_Event {
	position:absolute;
	width:138px;
	height:28px;
	z-index:3;
	left: 620px;
	top: 233px;
	visibility:hidden;
}
</style>

<style type="text/css">

#ddcolortabs{
margin-left: 2px;
padding: 0;
width: 100%;
background: transparent;
voice-family: "\"}\"";
voice-family: inherit;
padding-left: 2px;
}

#ddcolortabs ul{
font: bold 12px Arial, Verdana, sans-serif;
margin:0;
padding:0;
list-style:none;
}

#ddcolortabs li{
display:inline;
margin:0 2px 0 0;
padding:0;
text-transform:uppercase;
}


#ddcolortabs a{
float:right;
color: white;
background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top;
margin:115px 2px 0 0;
padding:0px 0 1px 3px;
text-decoration:none;
letter-spacing: 1px;
}

#ddcolortabs a span{
float:right;
display:block;
/*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/
padding:9px 9px 2px 6px;
}

#ddcolortabs a span{
float:none;
}


#ddcolortabs a:hover{
background-color: #678b3f;
}

#ddcolortabs a:hover span{
background-color: #678b3f ;
}

#ddcolortabs #current a, #ddcolortabs #current span{ /*currently selected tab*/
background-color: #678b3f;
}
</style>

<style type="text/css">
#Layer4_horizontal_line {
	position:absolute;
	width:980px;
	height:5px;
	z-index:3;
	left: 0px;
	top: 151px;
}
#green_frame {
	position:absolute;
	width:172px;
	height:384px;
	z-index:4;
	left: 0px;
	top: 156px;
}
#Layer1_background_green {
	position:absolute;
	width:980px;
	height:392px;
	z-index:1;
	top: 149px;
	left: 0px;
}

#nav_vertical {
	position:absolute;
	width:182px;
	height:113px;
	z-index:5;
	left: 1px;
	top: 361px;
}
#nav_vertical ul{
font: bold 12px Arial, Verdana, sans-serif;
margin:0;
padding:0;
list-style:none;
}

#nav_vertical li{
display:inline;
margin:0 0 0 0;
padding:0;
text-transform:uppercase;
}


#nav_vertical a{
float:left;
color: green;
/*background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top;*/
margin:0 2px 0 0;
padding:0 0 1px 3px;
text-decoration:none;
letter-spacing: 1px;
}

#nav_vertical a span{
float:left;
display:block;
/*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/
padding:9px 9px 2px 6px;
}


#nav_vertical a:hover{
color:#00CC00;
}

#nav_vertical a:hover span{
color: #00CC00 ;
}

#nav_vertical #current a, #nav_vertical #current span{ /*currently selected tab*/
/*background-color: #678b3f; */
color:#FFFFFF
}
#dunlop_lazenger {
	position:absolute;
	width:73px;
	height:72px;
	z-index:6;
	left: 0px;
	top: 160px;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
#Cal_Events {
	position:absolute;
	width:200px;
	height:115px;
	z-index:7;
	left: 619px;
	top: 271px;
}
</style>
</head>

<body>
<form>
<div id="nav_vertical">
<ul>
<li id="current"><a href="Calendar_Event.php" title="CALENDAR EVENT" target="_self"><span>CALENDAR EVENT</span></a></li>
<li><a href="roland_garros.php" title="RONALD GARROS" target="_self"><span>ROLAND GARROS</span></a></li>
<li><a href="wimbledon.php" title="WIMBLEDON" target="_self"><span>WIMBLEDON</span></a></li>
</ul>
</div>
<div id="ddcolortabs">
<ul>
<li> <a href="Products.php" title="Products" target="_self"><span>Products</span></a></li>
<li id="current"><a href="Event.php" title="Events" target="_self"><span>Events</span></a></li>
<li style="margin-left: 1px"><a href="Company.php" title="Company" target="_self"><span>Company</span></a></li>
</ul>
</div>
<div id="ddcolortabsline"></div>
<div id="dunlop_lazenger"><img src="layout_image/dunlop_slazenger.png" width="170" height="200" /></div>
<div id="Layer1_background_green"><img src="layout_image/LINE.png" width="1020" height="417" /></div>
<div id="green_frame"><img src="layout_image/vertical left v01.jpg" width="174" height="410" /></div>
<div id="Layer4_horizontal_line"><img src="layout_image/horizontal_line.png" width="1020" height="5" /></div>
</form>
<?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 = '<span>' . $tDayName . '</span>';
$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;
}
?>
<div id="Calendar_Event">
<table width="350" cellpadding="0" cellspacing="0">
<tr>
<td width="50" colspan="1">
<input type="button" value=" < " onclick="goLastMonth(<?php echo $month . ", " . $year; ?>);">
</td>
<td width="250" colspan="5">
<span class="title" style="color:#FFFFFF"><?php echo $monthName . " " . $year; ?></span><br>
</td>
<td width="50" colspan="1" align="right">
<input type="button" value=" > " onclick="goNextMonth(<?php echo $month . ", " . $year; ?>);">
</td>
</tr> 
<tr>
<th>M</td>
<th>T</td>
<th>W</td>
<th>T</td>
<th>F</td>
<th>S</td>
<th>S</td>
</tr>
<tr>
<?php
for($i = 1; $i < $numDays+1; $i++, $counter++){
$dateToCompare = $month . '/' . $i . '/' . $year;
$timeStamp = strtotime("$year-$month-$i");
//echo $timeStamp . '<br/>';
if($i == 1){
// Workout when the first day of the month is
$firstDay = date("N", $timeStamp);
for($j = 1; $j < $firstDay; $j++, $counter++){
echo "<td>&nbsp;</td>";
} 
}
if($counter % 7 == 0 ){
?>
</tr><tr>
<?php
}
?>
<!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td> 
<?php
}
?>
</table>
</div>
<div id="New_Event">
<?php
if(isset($_GET['v'])){
if(isset($_POST['Submit'])){
$sql="insert into calTbl(calName,calDesc,calDate) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())";
mysql_query($sql);
}
$sql="select calName,calDesc from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";
//echo $sql;
//return;
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);
?>
<a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">New Even</a><a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true"  >t</a><br/>
</div>
<div id="Cal_Events">
<?php
if(isset($_GET['f'])){
include 'calForm.php';
}
if($numRows == 0 ){
echo '<h3>No Events</h3>';
}else{
//echo '<ul>';
echo '<h3>Events Listed</h3>';
while($row = mysql_fetch_array($result)){
?>

<h5><?=$row['calName'];?></h5>
<?=$row['calDesc'];?><br/>
<?php
}
}
}
?>
</div>
</body>
</html>



I don't know how to unhide the link if the user is xxx and the department is yyy.


I hope somebody can help me...

Thank you

Is This A Good Question/Topic? 0

Replies To: Adding Events in Calendar

#2 guahguahmonster  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 68
  • View blog
  • Posts: 209
  • Joined: 29-August 07

Re: Adding Events in Calendar

Posted 23 August 2010 - 12:44 AM

A few ways to do it. Pick one that looks nicest to you.

<?php
if ($user == "OldMacdonald" && $department == "Farming") {
    echo '<a href="super_secret_page.php">My super secret page!</a>';
}
?>



Or

<?php if ($user == "OldMacdonald" && $department == "Farming") { ?>
<a href="super_secret_page.php">My super secret page!</a>
<?php } ?>



Or

<?php if ($user == "OldMacdonald" && $department == "Farming") : ?>
<a href="super_secret_page.php">My super secret page!</a>
<?php endif; ?>


Was This Post Helpful? 0
  • +
  • -

#3 Guest_newphpcoder*


Reputation:

Re: Adding Events in Calendar

Posted 31 August 2010 - 12:19 AM

View Postguahguahmonster, on 22 August 2010 - 11:44 PM, said:

A few ways to do it. Pick one that looks nicest to you.

<?php
if ($user == "OldMacdonald" && $department == "Farming") {
    echo '<a href="super_secret_page.php">My super secret page!</a>';
}
?>



Or

<?php if ($user == "OldMacdonald" && $department == "Farming") { ?>
<a href="super_secret_page.php">My super secret page!</a>
<?php } ?>



Or

<?php if ($user == "OldMacdonald" && $department == "Farming") : ?>
<a href="super_secret_page.php">My super secret page!</a>
<?php endif; ?>



I try the code thAt you suggested, the good is theres no error that i encountered..but eventhough i login as the username is xxx and the department is yyy which is the one who can add event. the link where i wish i can press to make add event was not appear.

this is the code:
<?php
$sql="Select Username, Department from tbllogin where Username =='xxx' && Department=='yyy'";
mysql_query($sql);
$username = $_POST['Username'];
$department = $_POST['Department'];
if($username=='xxx' && $department=='yyy') : ?>
echo '<a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">New Even</a><a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true" >t</a>';
<?php endif;?>


Was This Post Helpful? 0

#4 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

Re: Adding Events in Calendar

Posted 31 August 2010 - 04:31 AM

Holy inline code Batman! You've got HTML, Javascript, CSS, and PHP all mixed together. It's no wonder you can't figure out where to do anything. Writing code is about organizing it into manageable chunks. Worry about that first, and fixing your problem will follow naturally.

Edit: Oh, and use indenting. It too will make your life easier.

This post has been edited by CTphpnwb: 31 August 2010 - 04:34 AM

Was This Post Helpful? 2
  • +
  • -

#5 Guest_newphpcoder*


Reputation:

Re: Adding Events in Calendar

Posted 02 September 2010 - 02:34 AM

Good day!

I created a webpage and it has a login page...I want that if the user was already login and she accidentally press the back button if the login page was view again she could not login again because she was already login..

I try to use session but i think it does not work. I have no idea on what code should i need to fix my problem.

here is my code:
<?php  
session_start(); 
//require_once 'conn.php';  
$db_name="dspi"; 

mysql_connect("localhost", "root", "") or die("Cannot connect to server");
mysql_select_db("$db_name")or die("Cannot select DB");   


        $department = mysql_real_escape_string($_POST['department']);   
        $username = mysql_real_escape_string($_POST['username']); 

        $sql=mysql_query("SELECT `Department`, `Username` FROM `tbllogin` WHERE `Department` = '{$department}' AND Username = '{$username}'") or die(mysql_error()); 
        $ct = mysql_num_rows($sql); 
     
        if($ct == 1) { 
            $row = mysql_fetch_assoc($sql);  
         
            if($row['Department']=='Accounting') { 
                header('location: Company.php'); 
            } elseif($row['Department']=='Engineering') { 
                header('location: Company.php'); 
            } elseif($row['Department']=='Finishing_Goods') { 
                header('location: Company.php'); 
            } elseif($row['Department']=='HRAD') { 
                header('location: Company.php'); 
            } elseif($row['Department']=='MIS') { 
                header('location:Company.php'); 
            } elseif($row['Department']=='Packaging_and_Design') { 
                header('location:Company.php'); 
            } elseif($row['Department']=='Production') { 
                header('location:Company.php'); 
            } elseif($row['Department']=='Purchasing_Logistic') { 
                header('location:Company.php'); 
            } elseif($row['Department']=='QA_and_Technical') { 
                header('location:Company.php'); 
            } elseif($row['Department']=='Supply_Chain') { 
                header('location:Company.php'); 
            } 
            else {
				header('location:index.php');
				echo"Incorrect Username or Department"; 
				
	        	}  
	}
?> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>DSPI LOGIN</title>
<script> 
        function searchKeyPress(e) 
        { 
                // look for window.event in case event isn't passed in 
                if (window.event) { e = window.event; } 
                if (e.keyCode == 13) 
                { 
                        document.getElementById('submit').focus(); 
                } 
        } 
        </script>
<style type="text/css"> 
<!--
BODY { 
background-image: url(layout_image/bgroundv09.png);
background-attachment: fixed; 
} 
#Dept_Frame {
	position:absolute;
	width:229px;
	height:49px;
	z-index:1;
	left: 441px;
	top: 262px;
}
#Department_Option {
	position:absolute;
	width:186px;
	height:32px;
	z-index:2;
	left: 453px;
	top: 275px;
}
#Submit_Frame {
	position:absolute;
	width:82px;
	height:35px;
	z-index:3;
	left: 516px;
	top: 320px;
}
#Submit_Button {
	position:absolute;
	width:60px;
	height:29px;
	z-index:4;
	left: 524px;
	top: 328px;
}
#Username_ImageText {
	position:absolute;
	width:130px;
	height:55px;
	z-index:5;
	left: 319px;
	top: 208px;
}
#User_Frame {
	position:absolute;
	width:230px;
	height:46px;
	z-index:6;
	left: 441px;
	top: 216px;
}
#Username_Textbox {
	position:absolute;
	width:182px;
	height:23px;
	z-index:7;
	left: 455px;
	top: 228px;
}
--> 
</style>  
</head>
<body>
<form id="form1" name="form1" method="post" action="">
  <div id="Department_Option">
    <select name="department" onkeypress="searchKeyPress(event);">
      <option>Choose your Department. . . . . . </option>
      <option value="Accounting" <?php if($_POST['department'] == 'Accounting') echo "selected='selected'"; ?>>Accounting</option>
      <option value="Engineering" <?php if($_POST['department'] == 'Engineering') echo "selected='selected'"; ?>>Engineering</option>
      <option value="Finishing_Goods" <?php if($_POST['department'] == 'Finishing_Goods') echo "selected='selected'"; ?>>Finishing Goods</option>
      <option value="HRAD" <?php if($_POST['department'] == 'HRAD') echo "selected='selected'"; ?>>HRAD</option>
      <option value="MIS" <?php if($_POST['department'] == 'MIS') echo "selected='selected'"; ?>>MIS</option>
      <option value="Packaging_and_Design" <?php if($_POST['department'] == 'Packaging_and_Design') echo "selected='selected'"; ?>>Packaging and Design</option>
      <option value="Production" <?php if($_POST['department'] == 'Production') echo "selected='selected'"; ?>>Production</option>
      <option value="Purchasing_Logistic" <?php if($_POST['department'] == 'Purchasing_Logistic') echo "selected='selected'"; ?>>Purchasing and Logistics</option>
      <option value="QA_and_Technical" <?php if($_POST['department'] == 'QA_and_Technical') echo "selected='selected'"; ?>>QA and Technical</option>
      <option value="Supply_Chain" <?php if($_POST['department'] == 'Supply_Chain') echo "selected='selected'"; ?>>Supply Chain</option>
    </select>
  </div>
  <div id="Submit_Button">
    <input type="Submit" name="submit" value="Submit" id="submit" onclick="doSomething();"/>
  </div>
  <div id="Dept_Frame"><img src="layout_image/subframev02.png" width="229" height="50" /></div>
  <div id="Submit_Frame"><img src="layout_image/subframev02.png" width="80" height="46" /></div>

<div id="Username_ImageText"><img src="layout_image/userv01.png" width="131" height="62" /></div>
<div id="User_Frame"><img src="layout_image/subframev02.png" width="229" height="50" /></div>
<div id="Username_Textbox">
  <input name="username" type="text" size="30" />
</div>
</form>
</body>
</html>

Was This Post Helpful? 0

#6 PhunkRabbit  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 81
  • View blog
  • Posts: 406
  • Joined: 23-August 10

Re: Adding Events in Calendar

Posted 02 September 2010 - 02:38 AM

When the user logs in you could set a session variable like so:

$_SESSION['logged'] = '1';



Then run an if statment at the top of the page:

if($_SESSION['logged'] == '1')
{
     header('Location:Company.php');
     exit();
}



PS. after using the header function you should use exit(); this prevents the script from running further after the header is set.

You may also need to use output buffering for the headers to work.
Was This Post Helpful? 0
  • +
  • -

#7 Guest_newphpcoder*


Reputation:

Re: Adding Events in Calendar

Posted 02 September 2010 - 05:23 PM

View PostPhunkRabbit, on 02 September 2010 - 01:38 AM, said:

When the user logs in you could set a session variable like so:

$_SESSION['logged'] = '1';



Then run an if statment at the top of the page:

if($_SESSION['logged'] == '1')
{
     header('Location:Company.php');
     exit();
}



PS. after using the header function you should use exit(); this prevents the script from running further after the header is set.

You may also need to use output buffering for the headers to work.




Thank you...i will try the suggested code
Was This Post Helpful? 0

#8 Guest_newphpcoder*


Reputation:

Re: Adding Events in Calendar

Posted 02 September 2010 - 07:06 PM

i want to share my problem in my website

For the better understandng of my website, I want to tell all the details.

1. I have a database and i has a 2 tables 1 for the tbllogin which consist of Username and Department, and the second table is caltbl which i use for the calendar events.

2.When my website run the first webpage is the login form. If the Username and Department is correct she can browse the other webpages, like the calendar event.


3. In the calendar event you can see the calendar and when you click the date theirs a link "new event" appear and if theirs no existing event theres a text saying "No Events", when you click the link you can add events. I want that theirs a specific person that can only add events for the restriction of adding events. I want to happen that if the user is xxx and her department is yyy the link shoud appear and she can add events. i want that only to her the link should be appear..
<?php
$host = "localhost";

	$username = "";

	$password = "";

	$dbCnx = @mysql_connect($host, $username, $password) or die('Could not Connect to the database');

	$dbName = 'dspi';

	mysql_select_db($dbName);	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>DSPI CALENDAR EVENTS</title>
<script>
function goLastMonth(month, year){
// If the month is January, decrement the year
if(month == 1){
--year;
month = 13;
}
document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month-1)+'&year='+year;
}
//next function
function goNextMonth(month, year){
// If the month is December, increment the year
if(month == 12){
++year;
month = 0;
}
document.location.href = '<?=$_SERVER['PHP_SELF'];?>?month='+(month+1)+'&year='+year;
} 

function remChars(txtControl, txtCount, intMaxLength)
{
if(txtControl.value.length > intMaxLength)
txtControl.value = txtControl.value.substring(0, (intMaxLength-1));
else
txtCount.value = intMaxLength - txtControl.value.length;
}

function checkFilled() {
var filled = 0
var x = document.form1.calName.value;
//x = x.replace(/^\s+/,""); // strip leading spaces
if (x.length > 0) {filled ++}

var y = document.form1.calDesc.value;
//y = y.replace(/^s+/,""); // strip leading spaces
if (y.length > 0) {filled ++}

if (filled == 2) {
document.getElementById("Submit").disabled = false;
}
else {document.getElementById("Submit").disabled = true} // in case a field is filled then erased

}

</script>
<style>
body{
background-image: url(layout_image/bgroundv09.png);
background-attachment: fixed; 
font-family:Georgia, "Times New Roman", Times, serif;
font-size:16px;
}
.today{
/*background-color:#00CCCC;*/
font-weight:bold;
font-style:italic;
border-bottom-style:dashed;
background-image:url(calBg.jpg);
background-repeat:no-repeat;
background-position:center;
position:relative;
color:#FFFF00;
}
.today span{
position:absolute;
left:0;
top:0; 
}

.today a{
color:#FFFF00;
padding-top:10px;
}
.selected {
color: #FFFFFF;
background-color: #C00000;
}
.event {
/*background-color: #C6D1DC;*/
/*border:1px solid #ffffff;*/
background-image:url(layout_image/boxv01.png);
border: 1px ;
/*border-bottom-style:dashed;*/
/*border color #427e1a;*/
} 
.normal {

} 
table{
border:1px solid #cccccc;
padding:3px;
}
th{
width:36px;
background-color:#bcdd24;
text-align:center;
color:#ffffff;
border-left:1px solid #ffffff;
}
td{
text-align:center;
padding:8px;
margin:0;
}
table.tableClass{
width:350px;
border:none;
border-collapse: collapse;
font-size:85%;
border:1px dotted #cccccc;
}
table.tableClass input,textarea{
font-size:90%;
}
#form1{
margin:5px 0 0 0;
}
#greyBox{
height:10px;
width:10px;
background-color:#C6D1DC;
border:1px solid #666666;
margin:5px;
}
#hr{border-bottom:1px solid #cccccc;width:300px;}
.output{width:300px;border-bottom:1px dotted #ccc;margin-bottom:5px;padding:6px;}
h5{margin:0;}

</style>
<style type="text/css">
#Calendar_Event {
	position:absolute;
	width:200px;
	height:94px;
	z-index:2;
	left: 255px;
	top: 233px;
}
#New_Event {
	position:absolute;
	width:126px;
	height:21px;
	z-index:3;
	left: 612px;
	top: 232px;
}
</style>

<style type="text/css">

#ddcolortabs{
margin-left: 2px;
padding: 0;
width: 100%;
background: transparent;
voice-family: "\"}\"";
voice-family: inherit;
padding-left: 2px;
}

#ddcolortabs ul{
font: bold 12px Arial, Verdana, sans-serif;
margin:0;
padding:0;
list-style:none;
}

#ddcolortabs li{
display:inline;
margin:0 2px 0 0;
padding:0;
text-transform:uppercase;
}


#ddcolortabs a{
float:right;
color: white;
background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top;
margin:115px 2px 0 0;
padding:0px 0 1px 3px;
text-decoration:none;
letter-spacing: 1px;
}

#ddcolortabs a span{
float:right;
display:block;
/*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/
padding:6px 9px 2px 6px;
}

#ddcolortabs a span{
float:none;
}


#ddcolortabs a:hover{
background-color: #678b3f;
}

#ddcolortabs a:hover span{
background-color: #678b3f ;
}

#ddcolortabs #current a, #ddcolortabs #current span{ /*currently selected tab*/
background-color: #678b3f;
}
</style>

<style type="text/css">
#Layer4_horizontal_line {
	position:absolute;
	width:980px;
	height:5px;
	z-index:3;
	left: 0px;
	top: 150px;
}
#green_frame {
	position:absolute;
	width:172px;
	height:384px;
	z-index:4;
	left: 0px;
	top: 156px;
}
#Layer1_background_green {
	position:absolute;
	width:980px;
	height:392px;
	z-index:1;
	top: 149px;
	left: 0px;
}

#nav_vertical {
	position:absolute;
	width:182px;
	height:113px;
	z-index:5;
	left: 1px;
	top: 361px;
}
#nav_vertical ul{
font: bold 12px Arial, Verdana, sans-serif;
margin:0;
padding:0;
list-style:none;
}

#nav_vertical li{
display:inline;
margin:0 0 0 0;
padding:0;
text-transform:uppercase;
}


#nav_vertical a{
float:left;
color: green;
/*background: #8cb85c url(layout_image/color_tabs_left.gif) no-repeat left top;*/
margin:0 2px 0 0;
padding:0 0 1px 3px;
text-decoration:none;
letter-spacing: 1px;
}

#nav_vertical a span{
float:left;
display:block;
/*background: transparent url(layout_image/color_tabs_right.gif) no-repeat right top;*/
padding:9px 9px 2px 6px;
}


#nav_vertical a:hover{
color:#00CC00;
}

#nav_vertical a:hover span{
color: #00CC00 ;
}

#nav_vertical #current a, #nav_vertical #current span{ /*currently selected tab*/
/*background-color: #678b3f; */
color:#FFFFFF
}
#dunlop_lazenger {
	position:absolute;
	width:73px;
	height:72px;
	z-index:6;
	left: 0px;
	top: 160px;
}
a:link {
	color: #FFFFFF;
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
#Cal_Event {
	position:absolute;
	width:166px;
	height:74px;
	z-index:7;
	left: 611px;
	top: 254px;
}
</style>
</head>

<body>
<form>
<div id="nav_vertical">
<ul>
<li id="current"><a href="Calendar_Event.php" title="CALENDAR EVENT" target="_self"><span>CALENDAR EVENT</span></a></li>
<li><a href="roland_garros.php" title="RONALD GARROS" target="_self"><span>ROLAND GARROS</span></a></li>
<li><a href="wimbledon.php" title="WIMBLEDON" target="_self"><span>WIMBLEDON</span></a></li>
</ul>
</div>
<div id="ddcolortabs">
<ul>
<li> <a href="Products.php" title="Products" target="_self"><span>Products</span></a></li>
<li id="current"><a href="Event.php" title="Events" target="_self"><span>Events</span></a></li>
<li style="margin-left: 1px"><a href="Company.php" title="Company" target="_self"><span>Company</span></a></li>
</ul>
</div>
<div id="ddcolortabsline"></div>
<div id="dunlop_lazenger"><img src="layout_image/dunlop_slazenger.png" width="170" height="200" /></div>
<div id="Layer1_background_green"><img src="layout_image/LINE.png" width="1020" height="417" /></div>
<div id="green_frame"><img src="layout_image/vertical left v01.jpg" width="174" height="410" /></div>
<div id="Layer4_horizontal_line"><img src="layout_image/horizontal_line.png" width="1020" height="5" /></div>
</form>
<?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 = '<span>' . $tDayName . '</span>';
$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;
}
?>
<div id="Calendar_Event">
<table width="350" cellpadding="0" cellspacing="0">
<tr>
<td width="50" colspan="1">
<input type="button" value=" < " onclick="goLastMonth(<?php echo $month . ", " . $year; ?>);">
</td>
<td width="250" colspan="5">
<span class="title" style="color:#FFFFFF"><?php echo $monthName . " " . $year; ?></span><br>
</td>
<td width="50" colspan="1" align="right">
<input type="button" value=" > " onclick="goNextMonth(<?php echo $month . ", " . $year; ?>);">
</td>
</tr> 
<tr>
<th>M</td>
<th>T</td>
<th>W</td>
<th>T</td>
<th>F</td>
<th>S</td>
<th>S</td>
</tr>
<tr>
<?php
for($i = 1; $i < $numDays+1; $i++, $counter++){
$dateToCompare = $month . '/' . $i . '/' . $year;
$timeStamp = strtotime("$year-$month-$i");
//echo $timeStamp . '<br/>';
if($i == 1){
// Workout when the first day of the month is
$firstDay = date("N", $timeStamp);
for($j = 1; $j < $firstDay; $j++, $counter++){
echo "<td>&nbsp;</td>";
} 
}
if($counter % 7 == 0 ){
?>
</tr><tr>
<?php
}
?>
<!--right here--><td width="50" <?=hiLightEvt($month,$i,$year);?>><a href="<?=$_SERVER['PHP_SELF'] . '?month='. $month . '&day=' . $i . '&year=' . $year;?>&v=1"><?=$i;?></a></td> 
<?php
}
?>
</table>
</div>
<div id="New_Event">
<?php
if(isset($_GET['v'])){
if(isset($_POST['Submit'])){
$sql="insert into calTbl(calName,calDesc,calDate,calStamp) values('" . $_POST['calName'] ."','" . $_POST['calDesc'] . "','" . $_POST['calDate'] . "',now())";
mysql_query($sql);
}
$sql="select calName,calDesc, DATE_FORMAT(calStamp, '%a %b %e %Y') as calStamp from calTbl where calDate = '" . $month . '/' . $day . '/' . $year . "'";
//echo $sql;
//return;
$result = mysql_query($sql);
$numRows = mysql_num_rows($result);

$check=mysql_query("SELECT * FROM tbllogin WHERE Username='rhoda.barrera@dunlop.ph' AND Department='MIS'");
if (mysql_num_rows($check)>0){ 
?>
<a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">New Even</a><a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' . $_GET['day'] . '&year=' . $_GET['year'];?>&v=1&f=true">t</a><?php
}else{
echo 'You cannot Add New Event';
}?>
</div>
<div id="Cal_Event">
<?php
if(isset($_GET['f'])){
include 'calForm.php';
}
if($numRows == 0 ){
echo '';
}else{
//echo '<ul>';
echo '<h3>Event Listed</h3>';
while($row = mysql_fetch_array($result)){
?>

<h5><?=$row['calName'];?></h5>
<?=$row['calDesc'];?><br/>
Listed On: <?=$row['calStamp'];?>
<?php
}
}
}
?>
</div>
</body>
</html>


Was This Post Helpful? 0

#9 CTphpnwb  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2834
  • View blog
  • Posts: 9,740
  • Joined: 08-August 08

Re: Adding Events in Calendar

Posted 02 September 2010 - 08:10 PM

Why is your code no different than it was at the start of this thread? And why would you expect us to make more of an effort to fix it than you?
Was This Post Helpful? 2
  • +
  • -

#10 gregwhitworth  Icon User is offline

  • Tired.
  • member icon

Reputation: 216
  • View blog
  • Posts: 1,602
  • Joined: 20-January 09

Re: Adding Events in Calendar

Posted 03 September 2010 - 12:22 PM

Quote

Why is your code no different than it was at the start of this thread? And why would you expect us to make more of an effort to fix it than you?


Touché.

I thought it looked familiar.
Was This Post Helpful? 0
  • +
  • -

#11 macosxnerd101  Icon User is offline

  • Self-Trained Economist
  • member icon




Reputation: 10183
  • View blog
  • Posts: 37,596
  • Joined: 27-December 08

Re: Adding Events in Calendar

Posted 03 September 2010 - 03:58 PM

Duplicate topics merged. Please avoid duplicate posting.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1