Weird problem (groupcheck)

This is a discussion on Weird problem (groupcheck) within the PHP General forums, part of the PHP Programming Forums category; Hello, I want to check an array, that's not the biggest problem. But now I'm having a real ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 05-22-2005
Bertman
 
Posts: n/a
Default Weird problem (groupcheck)

Hello,



I want to check an array, that's not the biggest problem. But now I'm having
a real weird situation. I have a file 'checklogin.php' this file put all the
groups where a user is member off in a array ($usergroups). I have a simple
file to test it 'test.php'. When I put 'test.php' in the 'root\login'
directory he will say exactly that I'm member off 2 groups (after I logged
in). But when I put 'test.php' in the 'root', he will say that i'm member
off 1 group. And when I put 'checklogin.php' in the root, he also will say
that i'm member off one group. It's pretty weird, because the files don't
have a path to other files except to 'incl\connect.php' (this file will make
a connection to my MySQL database)



Example below:

root\login\test1.php

- this one will say that i'm member off 2 groups

root\test.php

- this one will say that i'm member off 1 group



(root = top of the server)

root\login\checklogin.php

root\login\test1.php

root\test.php


# test.php
<?PHP
include 'include\connect.php';
include 'login\checklogin.php';
echo count($usergroups);
?>

# test1.php
<?PHP
include '..\include\connect.php';
include 'checklogin.php';
echo count($usergroups);
?>

# checklogin.php
<?php
if (isset($_COOKIE["UserID"])) {
if (isset($_COOKIE["Name"])) {
if (isset($_COOKIE["Pass"])) {
$userid = $_COOKIE["UserID"];
$name = $_COOKIE["Name"];
$pass = $_COOKIE["Pass"];
$query = mysql_query("SELECT * FROM cd_user WHERE User_loginname='$name'
AND User_password='$pass' AND User_id='$userid'") or die (mysql_error());
if (mysql_num_rows($query)=='0') {
$usergroup='0'; // 0 zijn public groepen
$usergroups='0';
$name='';
} else { # mysql_num_rows($query)=='0'
$usergroups='';
$count='0';
while($result = mysql_fetch_array($query)){
$userid = $result["User_id"];
$query1 = mysql_query("SELECT * FROM cd_user_and_group WHERE
User_id='$userid'") or die (mysql_error());
while($result1 = mysql_fetch_array($query1)){
$usergroups[$count] = $result1["Group_id"]; //Maak een array aan met
alle group nummers
$count = $count + 1;
}
}
} # mysql_num_rows($query)=='0'
}else{
//Pass not set.
$usergroup='0'; // 0 zijn public groepen
$usergroups='0';
$name='';
}
}else{
//name not set.
$usergroup='0'; // 0 zijn public groepen
$usergroups='0';
$name='';
}
}else{
//userid not set.
$usergroup='0'; // 0 zijn public groepen
$usergroups='0';
$name='';
}
?>


Reply With Quote
  #2 (permalink)  
Old 05-23-2005
Bertman
 
Posts: n/a
Default Re: Weird problem (groupcheck)

Hello,

I found what's wrong, but now I need a sollution.
In the directory 'root\login' is also where the cookie is created. The
cookie is only active for this directory. But I want the cookie to be active
for the complete website, from root to the lowest directory. But when I put
a webaddress in the setcookie function it doesn't set a cookie

For explample (form php.net)
setcookie ("TestCookie", "test",time()+3600, "/~rasmus/", ".utoronto.ca",
1);


"Bertman" <Bertman@bertman.speedxs.nl> schreef in bericht
news:f6Gdnar3xYMcIhLfRVnyvQ@speedxs.nl...
> Hello,
>
>
>
> I want to check an array, that's not the biggest problem. But now I'm
> having a real weird situation. I have a file 'checklogin.php' this file
> put all the groups where a user is member off in a array ($usergroups). I
> have a simple file to test it 'test.php'. When I put 'test.php' in the
> 'root\login' directory he will say exactly that I'm member off 2 groups
> (after I logged in). But when I put 'test.php' in the 'root', he will say
> that i'm member off 1 group. And when I put 'checklogin.php' in the root,
> he also will say that i'm member off one group. It's pretty weird, because
> the files don't have a path to other files except to 'incl\connect.php'
> (this file will make a connection to my MySQL database)
>
>
>
> Example below:
>
> root\login\test1.php
>
> - this one will say that i'm member off 2 groups
>
> root\test.php
>
> - this one will say that i'm member off 1 group
>
>
>
> (root = top of the server)
>
> root\login\checklogin.php
>
> root\login\test1.php
>
> root\test.php
>
>
> # test.php
> <?PHP
> include 'include\connect.php';
> include 'login\checklogin.php';
> echo count($usergroups);
> ?>
>
> # test1.php
> <?PHP
> include '..\include\connect.php';
> include 'checklogin.php';
> echo count($usergroups);
> ?>
>
> # checklogin.php
> <?php
> if (isset($_COOKIE["UserID"])) {
> if (isset($_COOKIE["Name"])) {
> if (isset($_COOKIE["Pass"])) {
> $userid = $_COOKIE["UserID"];
> $name = $_COOKIE["Name"];
> $pass = $_COOKIE["Pass"];
> $query = mysql_query("SELECT * FROM cd_user WHERE User_loginname='$name'
> AND User_password='$pass' AND User_id='$userid'") or die (mysql_error());
> if (mysql_num_rows($query)=='0') {
> $usergroup='0'; // 0 zijn public groepen
> $usergroups='0';
> $name='';
> } else { # mysql_num_rows($query)=='0'
> $usergroups='';
> $count='0';
> while($result = mysql_fetch_array($query)){
> $userid = $result["User_id"];
> $query1 = mysql_query("SELECT * FROM cd_user_and_group WHERE
> User_id='$userid'") or die (mysql_error());
> while($result1 = mysql_fetch_array($query1)){
> $usergroups[$count] = $result1["Group_id"]; //Maak een array aan met
> alle group nummers
> $count = $count + 1;
> }
> }
> } # mysql_num_rows($query)=='0'
> }else{
> //Pass not set.
> $usergroup='0'; // 0 zijn public groepen
> $usergroups='0';
> $name='';
> }
> }else{
> //name not set.
> $usergroup='0'; // 0 zijn public groepen
> $usergroups='0';
> $name='';
> }
> }else{
> //userid not set.
> $usergroup='0'; // 0 zijn public groepen
> $usergroups='0';
> $name='';
> }
> ?>
>



Reply With Quote
  #3 (permalink)  
Old 05-23-2005
Bertman
 
Posts: n/a
Default Re: Weird problem (groupcheck)

Hello,

Yeah I have it
This doesn't work
> setcookie ("TestCookie", "test",time()+3600, "/~rasmus/", ".domain.com",
> 1);


This one works:
> setcookie ("TestCookie", "test",time()+3600, "/~rasmus/", ".domain.com",
> 0);


Bert

"Bertman" <Bertman@bertman.speedxs.nl> schreef in bericht
news:Z7udnexoZKEtBQzfRVnyvw@speedxs.nl...
> Hello,
>
> I found what's wrong, but now I need a sollution.
> In the directory 'root\login' is also where the cookie is created. The
> cookie is only active for this directory. But I want the cookie to be
> active for the complete website, from root to the lowest directory. But
> when I put a webaddress in the setcookie function it doesn't set a cookie
>
> For explample (form php.net)
> setcookie ("TestCookie", "test",time()+3600, "/~rasmus/", ".utoronto.ca",
> 1);
>
>
> "Bertman" <Bertman@bertman.speedxs.nl> schreef in bericht
> news:f6Gdnar3xYMcIhLfRVnyvQ@speedxs.nl...
>> Hello,
>>
>>
>>
>> I want to check an array, that's not the biggest problem. But now I'm
>> having a real weird situation. I have a file 'checklogin.php' this file
>> put all the groups where a user is member off in a array ($usergroups). I
>> have a simple file to test it 'test.php'. When I put 'test.php' in the
>> 'root\login' directory he will say exactly that I'm member off 2 groups
>> (after I logged in). But when I put 'test.php' in the 'root', he will say
>> that i'm member off 1 group. And when I put 'checklogin.php' in the root,
>> he also will say that i'm member off one group. It's pretty weird,
>> because the files don't have a path to other files except to
>> 'incl\connect.php' (this file will make a connection to my MySQL
>> database)
>>
>>
>>
>> Example below:
>>
>> root\login\test1.php
>>
>> - this one will say that i'm member off 2 groups
>>
>> root\test.php
>>
>> - this one will say that i'm member off 1 group
>>
>>
>>
>> (root = top of the server)
>>
>> root\login\checklogin.php
>>
>> root\login\test1.php
>>
>> root\test.php
>>
>>
>> # test.php
>> <?PHP
>> include 'include\connect.php';
>> include 'login\checklogin.php';
>> echo count($usergroups);
>> ?>
>>
>> # test1.php
>> <?PHP
>> include '..\include\connect.php';
>> include 'checklogin.php';
>> echo count($usergroups);
>> ?>
>>
>> # checklogin.php
>> <?php
>> if (isset($_COOKIE["UserID"])) {
>> if (isset($_COOKIE["Name"])) {
>> if (isset($_COOKIE["Pass"])) {
>> $userid = $_COOKIE["UserID"];
>> $name = $_COOKIE["Name"];
>> $pass = $_COOKIE["Pass"];
>> $query = mysql_query("SELECT * FROM cd_user WHERE User_loginname='$name'
>> AND User_password='$pass' AND User_id='$userid'") or die (mysql_error());
>> if (mysql_num_rows($query)=='0') {
>> $usergroup='0'; // 0 zijn public groepen
>> $usergroups='0';
>> $name='';
>> } else { # mysql_num_rows($query)=='0'
>> $usergroups='';
>> $count='0';
>> while($result = mysql_fetch_array($query)){
>> $userid = $result["User_id"];
>> $query1 = mysql_query("SELECT * FROM cd_user_and_group WHERE
>> User_id='$userid'") or die (mysql_error());
>> while($result1 = mysql_fetch_array($query1)){
>> $usergroups[$count] = $result1["Group_id"]; //Maak een array aan met
>> alle group nummers
>> $count = $count + 1;
>> }
>> }
>> } # mysql_num_rows($query)=='0'
>> }else{
>> //Pass not set.
>> $usergroup='0'; // 0 zijn public groepen
>> $usergroups='0';
>> $name='';
>> }
>> }else{
>> //name not set.
>> $usergroup='0'; // 0 zijn public groepen
>> $usergroups='0';
>> $name='';
>> }
>> }else{
>> //userid not set.
>> $usergroup='0'; // 0 zijn public groepen
>> $usergroups='0';
>> $name='';
>> }
>> ?>
>>

>
>



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 03:00 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0