Check DB and show page or not
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.
Re: Check DB and show page or not
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 Code:
<?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
}
?>
Re: Check DB and show page or not
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?
Re: Check DB and show page or not
Re: Check DB and show page or not
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.
Re: Check DB and show page or not
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:
PHP Code:
if($display['disabled'] == "true"){
Re: Check DB and show page or not
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"
Re: Check DB and show page or not
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'.
PHP Code:
$bln_disabled = isset($_POST['disabled']);
Re: Check DB and show page or not
and what if it is check when the page loads?
Re: Check DB and show page or not
it is set so it would return true.