Re: Login Form
| From: | Justin Patrin | Date: | Tue, 19 Oct 2004 17:32:19 +0000 |
| Subject: | Re: Login Form | ||
| References: | 1 2 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-33982@lists.php.net to get a copy of this message | ||
On Tue, 19 Oct 2004 15:02:41 +0100, Ronan Lehane <rpl1@student.cs.ucc.ie> wrote:
> Sorry there just read on, my $db should be created in my db_connect.php,
> does this look ok,
> $db = DB::connect($datasource); // attempt connection
> ?
>
Yes, that looks ok. Try putting this just before the call that's erroring out.:
print_r($db);
If this outputs nothing, then your variable isn't being set. If this
is a PEAR_Error, then the connection failed.
> Regards,
> Ronan
>
> -----Original Message-----
> From: Justin Patrin [mailto:papercrane@gmail.com]
> Sent: 18 October 2004 22:29
> To: Ronan Lehane
> Cc: pear-dev@lists.php.net
> Subject: Re: [PEAR-DEV] Login Form
>
> On Mon, 18 Oct 2004 17:10:22 +0100, Ronan Lehane <rpl1@student.cs.ucc.ie>
> wrote:
> > Hi All,
> > I have had a look around there and realise ye may be sick of haering this
> > question but I really can't find the answer.
> > I have a login script that will leave me log in but if I try to logout it
> > says
> > Fatal error: Call to a member function on a non-object in
> > C:\xampplite\htdocs\project\db\check_login.php on line 21
> >
> > logout.php
> > <?php
> >
> > require 'db_connect.php';
> >
> > if ($logged_in == 0)
> > {
> > die('You are not logged in so you cannot log out');
> > }
> >
> > unset($_SESSION['username']);
> > unset($_SESSION['password']);
> > //kill the session variables
> >
> > $_SESSION = array(); //reset the session array.
> >
> > session_destroy(); //destroy the session
> > header('Location:index.php');
> > //redirect to index page
> >
> > ?>
> >
> > and check_user.php login 21 is
> > $pass = $db->query("SELECT password FROM users WHERE username =
> > '".$_SESSION['username']."'");
> >
> > Any help would be greatly appreciated
> >
> > Regards,
> > Ronan
> >
>
> Assuming you're using PEAR::DB, try putting this at the beginning of
> your scipt (after including PEAR.php):
>
> PEAR::setErrorHandling(PEAR_ERROR_DIE);
>
> Likely your DB connect isn't working or perhaps $db isn't even created?
>
> --
> paperCrane --Justin Patrin--
>
--
paperCrane --Justin Patrin--