Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Problem in PHP Calendar Event

  1. #11
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by fastsol1 View Post
    I think I may have found the issue. You have { in your comments that you and I assumed was not acting in the code but it seems to be using it. Delete that and try it.
    PHP Code:
    //if (mysql_num_rows($check)>0){ 
    I do what you suggested

    PHP Code:
    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='HRAD' AND Permission='True'");
    $check2 = mysql_fetch_array($check1);
    if($check2['Username']=='sammy' && $check2['Department']=='HRAD' && $check2['Department']=='True'){
    $_SESSION['isallowed'] = $check2['Permission']; 

    ?>
    <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' $_GET['day'] . '&year=' $_GET['year'];?>&v=1&f=true">Add 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';
    }
    ?>
    when sammy was login he cannot add event even he is the one who permitted to add event. When he try to add event the message "You cannot Add New Event" was appear and when some user login who are not permitted to login the message "You cannot Add New Event" was appear that is correct.

  2. #12
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    I delete the comment that you said

    code:

    PHP Code:
    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='HRAD' AND Permission='True'");
    $check2 = mysql_fetch_array($check1);
    if($check2['Username']=='sammy' && $check2['Department']=='HRAD' && $check2['Department']=='True'){
    $_SESSION['isallowed'] = $check2['Permission']; 

    ?>
    <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' $_GET['day'] . '&year=' $_GET['year'];?>&v=1&f=true">Add 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';
    }
    ?>
    when sammy is login and he try to add event instead the add event link will appear the message "You cannot Add New Event " was appear and when the other user try to add event the message "You cannot Add New Event" appear which is correct.

  3. #13
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    I noticed now that you are checking Department for 2 different values instead of using the Permission for one of them. Change it to this and let me know.
    PHP Code:
    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='HRAD' AND Permission='True'");
    $check2 mysql_fetch_array($check1);
    if(
    $check2['Username']=='sammy' && $check2['Department']=='HRAD' && $check2['Permission']=='True'){
    $_SESSION['isallowed'] = $check2['Permission']; 
    If that stills does not work then you need to start echoing out the info you are getting from the db and compare it to the variables you want them to equal. So then do this:
    PHP Code:
    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='HRAD' AND Permission='True'");
    $check2 mysql_fetch_array($check1);
    $username $check2['Username'];
    $dep $check2['Department'];
    $permiss $check2['Permission'];
    echo 
    "$username<br/>$dep<br/>$permiss<br/><br/>";
    if(
    $username=="sammy" && $dep=="HRAD" && $permiss=="True"){
    $_SESSION['isallowed'] = $check2['Permission']; 

  4. #14
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by fastsol1 View Post
    I noticed now that you are checking Department for 2 different values instead of using the Permission for one of them. Change it to this and let me know.
    PHP Code:
    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='HRAD' AND Permission='True'");
    $check2 mysql_fetch_array($check1);
    if(
    $check2['Username']=='sammy' && $check2['Department']=='HRAD' && $check2['Permission']=='True'){
    $_SESSION['isallowed'] = $check2['Permission']; 
    If that stills does not work then you need to start echoing out the info you are getting from the db and compare it to the variables you want them to equal. So then do this:
    PHP Code:
    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='HRAD' AND Permission='True'");
    $check2 mysql_fetch_array($check1);
    $username $check2['Username'];
    $dep $check2['Department'];
    $permiss $check2['Permission'];
    echo 
    "$username<br/>$dep<br/>$permiss<br/><br/>";
    if(
    $username=="sammy" && $dep=="HRAD" && $permiss=="True"){
    $_SESSION['isallowed'] = $check2['Permission']; 

    Thank you for the suggested code. I try the code and the result is when sammy is login and he try to add event his username, department, and permission was appear and also the add even. Then I try to login as different user. The problem is when the user try to adtd event the username, department, permission of sammy was appear even he is not sammy and also the add event link was appear also. i want that if other user try to add event the message "You cannot add Event" Appear and only to sammy the add event link appear.

    I have an idea that i could not echo the information of sammy because in all user who try to add event all the information of sammy appear to them.I am right??

    Thank you...

  5. #15
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    I'm starting to get this now, I understood all along what you are trying to do but I'm understanding how we need to check this.
    First we need to check if the current user is in fact sammy and then run the query if he is or echo You cannot Add New Event is it is not. The key is the first part of that last sentence.
    Try this, this will only work is $_SESSION['username'] is set from the login.
    PHP Code:
    <?php
    if ($_SESSION['username']=="sammy")
    {
    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='HRAD' AND Permission='True'");
    $check2 mysql_fetch_array($check1);
    $username $check2['Username'];
    $dep $check2['Department'];
    $permiss $check2['Permission'];
    echo 
    "$username<br/>$dep<br/>$permiss<br/><br/>";
    if(
    $username=="sammy" && $dep=="HRAD" && $permiss=="True"){
    $_SESSION['isallowed'] = $check2['Permission'];

    ?>
    <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' $_GET['day'] . '&year=' $_GET['year'];?>&v=1&f=true">Add Event</a>
    <?php 
    }
    else
    { echo 
    "You cannot Add New Event"; }
    ?>

  6. #16
    Join Date
    Jul 2010
    Posts
    228
    Thanks
    18
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by fastsol1 View Post
    I'm starting to get this now, I understood all along what you are trying to do but I'm understanding how we need to check this.
    First we need to check if the current user is in fact sammy and then run the query if he is or echo You cannot Add New Event is it is not. The key is the first part of that last sentence.
    Try this, this will only work is $_SESSION['username'] is set from the login.
    PHP Code:
    <?php
    if ($_SESSION['username']=="sammy")
    {
    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='HRAD' AND Permission='True'");
    $check2 mysql_fetch_array($check1);
    $username $check2['Username'];
    $dep $check2['Department'];
    $permiss $check2['Permission'];
    echo 
    "$username<br/>$dep<br/>$permiss<br/><br/>";
    if(
    $username=="sammy" && $dep=="HRAD" && $permiss=="True"){
    $_SESSION['isallowed'] = $check2['Permission'];

    ?>
    <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' $_GET['day'] . '&year=' $_GET['year'];?>&v=1&f=true">Add Event</a>
    <?php 
    }
    else
    { echo 
    "You cannot Add New Event"; }
    ?>

    This code was solved my problem. But when i try it first i got an parse error because the first if statement was not close and i close it, so the error was solve. And also the echo of username i deleted.

    This is my code:
    PHP Code:
    if ($_SESSION['username']=="rhoda.barrera@dunlop.ph") 

    $check1=mysql_query("SELECT * FROM tbllogin WHERE Username='sammy' AND Department='MIS' AND Permission='True'"); 
    $check2 = mysql_fetch_array($check1); 
    $username = $check2['Username']; 
    $dep = $check2['Department']; 
    $permiss = $check2['Permission']; 
    //echo "$username<br/>$dep<br/>$permiss<br/><br/>"; 
    if($username=="sammy" && $dep=="MIS" && $permiss=="True"){ 
    $_SESSION['isallowed'] = $check2['Permission']; 

    ?> 
    <a href="<?=$_SERVER['PHP_SELF'];?>?month=<?=$_GET['month'] . '&day=' $_GET['day'] . '&year=' $_GET['year'];?>&v=1&f=true">Add 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"; } 

    ?>
    And the result of this code is when the user sammy was login the add event was appear and the rest user the message "You Cannot Add New Event" was appear to them because they are not permitted to add event. That's what i want to make happen. ANd now it happened..

    Thank you so much....

  7. #17
    Join Date
    Jul 2010
    Location
    Minnesota
    Posts
    256
    Thanks
    1
    Thanked 21 Times in 21 Posts

    Default

    good deal, glad it worked.

  8. The Following User Says Thank You to fastsol1 For This Useful Post:

    rhodarose (10-20-2010)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •