Click to See Complete Forum and Search --> : Check DB and show page or not
dclamp
Oct 12th, 2006, 09:21 PM
I want to make it so that in my admin area, i can diable the customer login. i have a table "disable_customer_login" with the fields "disabled (bool), message, date"
when the user visits the page it checks if login is enable and either displays the customer page, or diaplays the message and date.
kows
Oct 12th, 2006, 09:53 PM
I'm assuming you mean you're really actually disabling the ability for a customer to login, and not just making it to the login screen doesn't show up when they're logged in. If you just want to make it so the login screen doesn't show up when they're logged in, you're better off making a global variable (something like a boolean named $login) that will decide if the message/date is displayed instead of the login. otherwise, you can use something like this:
<?php
$displayq = mysql_query("SELECT disabled, message, date FROM disable_customer_login");
$display = mysql_fetch_array($displayq);
if($display['disabled']){
//disabled is true, do whatever you wanted to here
}else{
//disabled is false, do whatever else
}
?>
dclamp
Oct 12th, 2006, 11:03 PM
yeah, like in my admin area, i want to beable to have a page that can set the login to enabled or disabled. If the login is disabled, then a message appears, if not then the login form displays normaly.
so is that the code that i would use?
kows
Oct 12th, 2006, 11:45 PM
yes.
dclamp
Oct 15th, 2006, 11:03 PM
i dont think that is the code that i am looking for. Here is exactly what i want to happen:
1. I go to my admin page and disable login for admin.
a. on that admin page there is a check box. when check, the login is disabled, when unchecked, login is enabled.
b. I press "Submit"
2. I visit the Customer Login page and it should display "Sorry, customer....".
3. I go back to that admin page and uncheck the checkbox. press submit
4. I go to customer login and the login form displays normatly.
kows
Oct 16th, 2006, 12:07 AM
mhmm, that's the code you want... it does exactly what you're asking for.. you still have to make the page that does the checkbox stuff :/ the only thing i could think of you having a problem with is the value of $display['disabled'].. so, change the line to this instead:
if($display['disabled'] == "true"){
dclamp
Oct 16th, 2006, 07:43 PM
how do i make it so that when i press the submit button, and the checkbox is checked, it sets "disabled" to true and when it is not checked, it sets it to "false"
hairball
Oct 16th, 2006, 08:45 PM
A checkbox is not set when it is unchecked. You can use isset function.
Assuming that you are using POST method and the name of the checkbox is 'disabled'.
$bln_disabled = isset($_POST['disabled']);
dclamp
Oct 16th, 2006, 09:35 PM
and what if it is check when the page loads?
hairball
Oct 16th, 2006, 09:44 PM
it is set so it would return true.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.