Skip to main content
Inspiring
March 10, 2008
Question

Log in Set Cookie if field = 1

  • March 10, 2008
  • 4 replies
  • 406 views
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
This topic has been closed for replies.

4 replies

davecheetAuthor
Inspiring
March 14, 2008
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
Inspiring
March 15, 2008
Great I am glad you got it working, sometimes rest is the best
davecheetAuthor
Inspiring
March 13, 2008
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
Inspiring
March 13, 2008
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);
Inspiring
March 12, 2008
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);
davecheetAuthor
Inspiring
March 12, 2008
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