Re: Session again !!!
| From: | Dre | Date: | Sun, 05 Sep 2004 15:57:59 +0000 |
| Subject: | Re: Session again !!! | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-195925@lists.php.net to get a copy of this message | ||
it does not actually exist in the real code
I just added it to show that there are 2 equal signs in there
"Andre Dubuc" <aajdubuc@webhart.net> wrote in message
news:200409051145.02885.aajdubuc@webhart.net...
> Hi,
>
> In your code:
>
> if($_SESSION['uname'] = = "")
> ^
>
> Get rid of that extra space bewteen the ==
> Hth, Andre
>
>
>
> On Sunday 05 September 2004 11:23 am, Dre wrote:
> > I really did
> > and it behaves the same
> >
> > I tried isset() also but there is no good it still does not work !!!
> >
> >
> > "Afan Pasalic" <afan@afan.net> wrote in message
> > news:413B21FF.8080601@afan.net...
> >
> > > Try use
> > >
> > > if(empty($_SESSION['uname'])
> > >
> > > instead
> > >
> > > if($_SESSION['uname'] = = "")
> > >
> > >
> > > Afan
> > >
> > > Dre wrote:
> > > >Hi ..
> > > >
> > > >I'm still working on my members login script.
> > > >
> > > >I'm using a simple username/password login form that calls the
following
> > > >login script
> > > >//=====================================================
> > > ><?php session_start();
> > > > $username = trim(addslashes($_POST['user_name']));
> > > > $pass = trim(addslashes($_POST['password']));
> > > >
> > > > if((empty($_POST['user_name'])) ||
> > > > (empty($_POST['password'])))
> > > > {
> > > > header('Location: index.php');
> > > > include("login_form");
> > > > exit();
> > > >
> > > > }
> > > > else{
> > > > include("db.php");
> > > > $sql = "SELECT * FROM members_data WHERE
user_name='".$username."'
> >
> > AND
> >
> > > >password='".$pass."'";
> > > > $result = mysql_query($sql);
> > > > $num_return = mysql_num_rows($result);
> > > >
> > > > if($num_return ==1)
> > > > {
> > > > $row = mysql_fetch_array($result);
> > > > //session_register('uname');
> > > >
> > > > $_SESSION['uname'] = $username;
> > > > header('Location: /members/main.php');
> > > > }
> > > > else {
> > > > }
> > > > }
> > > >?>
> > > >//=====================================================
> > > >
> > > >the login scrip works fine .. and it directs me to the correct
landing
> >
> > page
> >
> > > >The problem occures when I tried to secure the members area pages
using
> >
> > the
> >
> > > >following code in the begining of each page
> > > >//=====================================================
> > > ><?php session_start();
> > > > if($_SESSION['uname'] = = "")
> > > > {header('Location: ../../index.php');
> > > > exit();
> > > > }
> > > > else{}
> > > >?>
> > > ><html>
> > > >... other html code
> > > ></html>
> > > >//=====================================================
> > > >After I login using the correct user name and password I get always
> > > >re-directed to that index page as if I'm not logged in
> > > >
> > > >I'm really so new with the sessions usage so I can't figure out what
do
> > > > I miss here
> > > >any help would be appreciated.
> > > >
> > > >Thanks in advance