Results 1 to 10 of 10

Thread: Check DB and show page or not

  1. #1

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    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.
    My usual boring signature: Something

  2. #2
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    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
      
    }
    ?>
    Like Archer? Check out some Sterling Archer quotes.

  3. #3

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    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?
    My usual boring signature: Something

  4. #4
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    Re: Check DB and show page or not

    yes.
    Like Archer? Check out some Sterling Archer quotes.

  5. #5

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    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.
    My usual boring signature: Something

  6. #6
    PowerPoster
    Join Date
    Sep 2003
    Location
    Edmonton, AB, Canada
    Posts
    2,629

    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"){ 
    Last edited by kows; Oct 16th, 2006 at 12:11 AM.
    Like Archer? Check out some Sterling Archer quotes.

  7. #7

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    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"
    My usual boring signature: Something

  8. #8
    Junior Member hairball's Avatar
    Join Date
    Aug 2006
    Location
    i'm not here.
    Posts
    24

    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']); 

    Break out from your mental box.
    I found better company. Iced chocolate with coffee jelly, anyone?

  9. #9

    Thread Starter
    WiggleWiggle dclamp's Avatar
    Join Date
    Aug 2006
    Posts
    3,527

    Re: Check DB and show page or not

    and what if it is check when the page loads?
    My usual boring signature: Something

  10. #10
    Junior Member hairball's Avatar
    Join Date
    Aug 2006
    Location
    i'm not here.
    Posts
    24

    Re: Check DB and show page or not

    it is set so it would return true.

    Break out from your mental box.
    I found better company. Iced chocolate with coffee jelly, anyone?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width