RE: login won't log in, HELP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



With an error level of E_ALL, you will also get warnings.  What this means,
is that any time there is a situation where a value is not passed to
$HTTP_POST_VARS['Submit'], it will throw a warning.  You can avoid getting
those warnings by using the empty function.

IE:

If(!empty($HTTP_POST_VARS['Submit']) && $HTTP_POST_VARS['Submit']=='Login')
	{
	}

That way it makes certain that variable is actually populated before it
checks its value against what you expect it to be.  If it's empty (is_null
works too, but I prefer empty), it doesn't bother checking the value of that
function.

Another great use of empty would be in this situation:

If you're posting a form, and you have the first textbox filled, you don't
need to check a hidden variable to make sure they submitted the form, simply
do this:

If(!empty($_POST["pUsername"]) && !empty($_POST["pPassword"]))
	{
		do your login checks here, and initiate the session
	}


Here would be the HTML code:

<form method="post" action="<? Print($_SERVER["PHP_SELF"]); ?>">
	<input type="text" name="pUsername">
	<input type="password" name="pPassword">
	<input type="submit" value="login">
</form>

Using checks like that will also help make your code more OS independent.
Most of the code I write works with very minor changes, and using the
default configuration, whether you throw it on *nix or win32.

I don't want to say this is the right way to code, but it's the best I've
found, and it's grown into my style.

Hope this helps,


___________________________________
Ryan Marrs
Web Developer
Sandler & Travis Trade Advisory Services, Inc.
248.474.7200 x 183
248.474.8500 (fax)
www.strtrade.com


-----Original Message-----
From: David [mailto:cddllc@hotmail.com] 
Sent: Tuesday, December 17, 2002 10:51 AM
To: php-db@lists.php.net
Subject: Re:  login won't log in, HELP

Thank You Jason for replying back.

I am still new to this and sometimes it is hard to ask question because I
don't know all the terms or how to word my problem.

Ok I switch my php.ini to error reporting to maximum (error_reporting  =
E_ALL)  and write off the bat I got this error message.

Notice: Undefined index: Submit in c:\program files\apache
group\apache\htdocs\sunwestsilver\admin\tmp3hdt979rwz.php on line 5

My code at that line is:

#    // This section is only run when the form has been submitted
#    if($HTTP_POST_VARS['Submit']=='Login') (This is line 5)
#  {
#    session_start();
#    // Check whether the login details are correct, and put
#   // the user status into a session variable.
#   $statusCheck = check_login($HTTP_POST_VARS);
#   if ($statusCheck == "Admin" || $statusCheck == "Staff")
#      {
#      session_register("statusCheck");
#      header("Location: menu.php");
#     }
#  }

>Rather than debug your code for you, here are a couple of pointers:
>
> 1) Bypass the login page, hardcode the login details and see whether that
gets
> you logged in.

This make sense.  I will try this. I got the code from "Dreamweaver MX: PHP
web Dev" book  and I double checked to make sure everything was type right,
I good. I can't write code out right from the head yet.  Remember I still
new to this and I am learning by reading code and try to visualize what is
going on and now learning to troubleshoot. ;-)

> 2) Use print_r() on your major variables in strategic places in your code
to
> see what's happening to them as they pass through your code.

Thx I will try this.  It will be my first time using it.

ThX for your help.  Could you help me with my error or see if this was
written it wrong.

ThX Jason

David

"Jason Wong" <php-db@gremlins.biz> wrote in message
200212171620.12094.php-db@gremlins.biz">news:200212171620.12094.php-db@gremlins.biz...
> On Tuesday 17 December 2002 14:42, David wrote:
> > Hello,
> >
> > I am pretty new to PHP and I am trying to create a admin login page so
my
> > client can view thier product line and orders.  I have MySQL set-up
> > properly and have data in it and I am able to view information from the
db
> > with no problem. I do all my testing on my local machine before I blast
it
> > to the main web server.  I am using 2000XP Pro, Apache/1.3.23 (Win32)
and
> > PHP Ver. 4.2.3.  The main webserver is a Unix system.
> >
> > The problem I am having is I created a login.php and a include page
called
> > admin.inc.php.  I tried to log-in but the login.php reloads and the
login
> > fields are blank. It should go to the admin.php or give me some type of
> > error.  I get no errors message.  I was getting errors earlier but I
forgot
> > to put a ; on one line.
>
> If you've set error reporting to maximum (error_reporting  =  E_ALL) and
> you're still not getting any errors then it must be some faulty logic in
your
> code.
>
> > I going to copy my login.php and admin.inc.php code hoping that someone
> > could help my and point out what am I over looking.  I put a #pound sign
in
> > front of the code, I hope this is ok.
>
> Rather than debug your code for you, here are a couple of pointers:
>
> 1) Bypass the login page, hardcode the login details and see whether that
gets
> you logged in.
>
> 2) Use print_r() on your major variables in strategic places in your code
to
> see what's happening to them as they pass through your code.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
>
> /*
> "Wish not to seem, but to be, the best."
> -- Aeschylus
> */
>



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux