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

Log in Set Cookie if field = 1

Participant ,
Mar 10, 2008 Mar 10, 2008

Copy link to clipboard

Copied

Can anyone help me with this please.

I have a log in page which issues a cookie and seems to work brilliantly but now need to add the ability to activate/deactivate a user.
I've added an 'active' field to the database where active can only equal 1 or zero. So what I'd like to do now is edit the login script to deny login if the 'active' field = 0.

I'm sure it's quite straightforward but I'm afraid it's proving a bit beyond me. I've attached the existing code in case anyone has the time to help me out.

Cheers


Dave
TOPICS
Server side applications

Views

341
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
Enthusiast ,
Mar 11, 2008 Mar 11, 2008

Copy link to clipboard

Copied

You can modify the code to work how you want, you might get a red exclamation mark in your server behaviors panel, but the code will work on the server. try using this code in place of your query. This examples needs a coulmn named dcc_active in your db, change to what ever your is named.

mysql_select_db($database_con_dcc, $con_dcc);

$active_UserValue = 0; // Use 1 if that equals an active user

$query_rsLogin = sprintf("SELECT dcc_user, dcc_password FROM dcc_users WHERE dcc_user= '%s' AND dcc_password = '%s' AND dcc_active = '%s'", $myUsername_rsLogin,$myPassword_rsLogin,$active_UserValue);

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
Participant ,
Mar 12, 2008 Mar 12, 2008

Copy link to clipboard

Copied

Thanks Tried that Mike,

It won't let me log in using any user/password combination regardless or not active=1

I've attached the code I'm using now, just in case I misinterpreted your instructions.

Cheers

Dave


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
Enthusiast ,
Mar 12, 2008 Mar 12, 2008

Copy link to clipboard

Copied

Try just using the value in the recordset like this:
$query_rsLogin = sprintf("SELECT dcc_user, dcc_password, FROM dcc_users WHERE dcc_user= '%s' AND dcc_password = '%s' AND active = 1",
$myUsername_rsLogin,$myPassword_rsLogin);

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
Participant ,
Mar 13, 2008 Mar 13, 2008

Copy link to clipboard

Copied

Sorry Mike, that doesn't change anything. Still no-one can login.

Perhaps I should change tack, go back to the original login set up but put a kind of "IF active =1 redirect to new page" line at the top.

Do you think that would be more straight forward?

Dave

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
Participant ,
Mar 14, 2008 Mar 14, 2008

Copy link to clipboard

Copied

Sorry MIke,

It works perfectly.

I must have been tired last night and made a simple mistake. Started afresh this morning, punched it all in again and bingo! it worked first time.

Thanks for help.

Cheers


Dave

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
Enthusiast ,
Mar 14, 2008 Mar 14, 2008

Copy link to clipboard

Copied

LATEST
Great I am glad you got it working, sometimes rest is the best

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