Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Login Problem building with PHP and CS3

New Here ,
Jul 09, 2008 Jul 09, 2008

Copy link to clipboard

Copied

I have a site that requires a login. When I type in the username and pswd it redirects to the index page as planned. The problem is that I am not really logged in. I added a conditional statement which is suppose to show the customer name if the username and psw match which they do. And if it does not match it is suppose to say I am not logged in. Well it always says I am not logged in. Can someone please give suggestions?
TOPICS
Server side applications

Views

387
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 09, 2008 Jul 09, 2008

Copy link to clipboard

Copied

TC5Racer wrote:
> I added a conditional statement which is suppose to show the
> customer name if the username and psw match which they do. And if it does not
> match it is suppose to say I am not logged in. Well it always says I am not
> logged in. Can someone please give suggestions?

Your post is so long, the code is cut off by the news server. However,
it's obvious from the following section of code that you're using
deprecated PHP that no longer works.

> <?php
> session_start();
> session_register("sessFirstName");
> $sessFirstName = $HTTP_POST_VARS['Name'];
> ?>

To start off, session_start() has already been called earlier on the
page, so you shouldn't call it again. Secondly, both session_register()
and $HTTP_POST_VARS are deprecated elements of PHP that no longer work
on most servers. The code should be rewritten like this:

$_SESSION['FirstName'] = $_POST['Name'];

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 09, 2008 Jul 09, 2008

Copy link to clipboard

Copied

Hi,

I made the changes you had suggested, but I am still getting the same results. What should I try next?

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 09, 2008 Jul 09, 2008

Copy link to clipboard

Copied

TC5Racer wrote:
> if (@$row_rsUsers['Name'] == @$row_rsUsers['Pswd']) {

Unless the username and password are the same (highly insecure), this
will always equate to false. And why are you using the error control
operator (@)? It's totally meaningless in this context.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2008 Jul 10, 2008

Copy link to clipboard

Copied

Hi,

So I removed this statement f (@$row_rsUsers['Name'] == @$row_rsUsers['Pswd']) {from the page altogether. And now I am back to the original problem I was having.

Regardless of who I login as I only get logged in as the very first user. So regardless if I use credentials for customer number 1 or number 20 it always shows as customer number 1.

What should I try next?

Thanks for all your information...

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2008 Jul 10, 2008

Copy link to clipboard

Copied

TC5Racer wrote:
> Regardless of who I login as I only get logged in as the very first user. So
> regardless if I use credentials for customer number 1 or number 20 it always
> shows as customer number 1.

No, you're always logged in with the credentials entered into the login
form. The rsUsers recordset that you're creating has no relationship
whatsoever with the login procedure. Look at the following SQL query:

> $query_rsUsers = "SELECT user_id, Customers, Name, Pswd, `Level` FROM SignUp";

That selects *every* record in the SignUp table. You later use this
recordset to display the customers name, but since all records are
retrieved, you'll always get the first name regardless of who's logged in.

$_SESSION['MM_Username'] contains the username of the person logged in.
Either use that, or use it as a filter for the rsUsers recordset.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 10, 2008 Jul 10, 2008

Copy link to clipboard

Copied

David,

Thank you so much for your help. I used the session variable as you mentioned and that solved the problem.
Thanks again!

Art

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2008 Jul 10, 2008

Copy link to clipboard

Copied

LATEST
TC5Racer wrote:
> Thank you so much for your help. I used the session variable as you mentioned and that solved the problem.

Great. Glad you got it sorted.

--
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines