How to make this Form disappear once it performs its function

Discussion in 'PHP' started by chrisj, Sep 13, 2014.

  1. #1
    Although I know this isn't a state-of-the-art Log-In Form, it does function successfully.
    If the wrong credentials are entered the user is re-directed to a log-in page.
    If the correct credentials are entered the user stays on the homepage.
    What can I add to this so that when the correct credentials are entered, this Form disappears,
    until the user logs-out? Thanks for any help

    <form action="../login.php" method="post" accept-charset="UTF-8" class="middletext">
    <p>
    <style type="text/css">
    .form_label {
    font-size: 12px;
    color: #696969;
    margin: 0px 0px 20px 0px;
    }
    #user_name_login {
    width: 150px;
    height: 38px;
    border-style:solid;
    border-width: 1px;
    border-color:#e5e5e5;
    }
    #password_login {
    width: 150px;
    height: 38px;
    border-style:solid;
    border-width: 1px;
    border-color:#e5e5e5;
    }
    </style>
    
    <input type="text" size="20" name="user_name_login" id="user_name_login" value="ENTER USERNAME" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value=='ENTER USERNAME') {this.value=''; this.style.color='#696969';}" >
    <input type="text" size="20" name="password_login" id="password_login" value="ENTER PASSWORD" style="color:#D9D9D9" style="vertical-align:middle"; onfocus="if (this.value=='ENTER PASSWORD') {this.value=''; this.style.color='#696969';}" >
    
    <input type="hidden" name="cookie_time" value="10080" />
    
    <img src="../themes/default/images/arrow-red.png" alt="" /><input type="submit" style="outline:grey" font-size="5px" value="[var.lang_login_now]" class="button-form2" />
    <input type="hidden" name="submitted" value="yes" />
    <input type="hidden" name="remember_me" value="remember_me" />
    </p>
    </form>
    PHP:

     
    chrisj, Sep 13, 2014 IP
  2. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #2
    That's... just... so... ugly.
    Really. Inline javascript, CSS places haphazardly inside the <form> tag, value instead of placeholders, inline-CSS too...
    I really, really, REALLY suggest you rewrite this.
    For the hiding of the form, you can either do this by redirecting to another page (have the login as a separate page), or base it on a session or cookie and then hide the form based on that, or just add or remove an ID on body for loggedin/notloggedin and base the display of the form on that.
     
    PoPSiCLe, Sep 13, 2014 IP
  3. chrisj

    chrisj Well-Known Member

    Messages:
    606
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    Thanks for your reply.
    yes, I understand that the code can make modern coders cringe.
    I didn't write the script, I just use it. I'm no coder, so all the things that you suggested sound good,
    I just don't know how to code that.
    I thought maybe I could get a line of code to head me in that direction.
     
    chrisj, Sep 13, 2014 IP