Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 15 of 15
  1. #1
    Regular Coder
    Join Date
    Feb 2008
    Posts
    128
    Thanks
    1
    Thanked 0 Times in 0 Posts

    How to make this Form disappear once it performs its function

    Although I know this isn't state-of-the-art Log-In Form code, it does function successfully.
    Currently, if the wrong credentials are entered the user is re-directed to a log-in page,
    and if the correct credentials are entered the user stays on the home page.
    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

    Code:
    <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>

  • #2
    New Coder
    Join Date
    Aug 2014
    Posts
    97
    Thanks
    0
    Thanked 18 Times in 18 Posts
    You would just wrap the entire form in a if(){}. But since you have not provided any info as to how the site determines if a user is logged in, we can't tell you what to put in the in the if().

  • #3
    Regular Coder
    Join Date
    Feb 2008
    Posts
    128
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your reply.
    I don't know "how the site determines if a user is logged in".
    I'm using a script written by someone else.
    However, maybe this will help. Another part of the code on that page shows this:
    Code:
    <!--Begin Sub-Navigation.  This only appears when a user is logged in.-->
          <div class="sub-nav">
            <!--submenu 1-->
            <div class="sub-nav-links">
              <a href="myaccount.php">[var.lang_my_account]</a>
              &nbsp;|&nbsp;
              <a href="members/[var.user_name]">[var.lang_my_profile]</a>
              &nbsp;|&nbsp;
              <a href="emailinbox.php">[var.lang_word_email]&nbsp;<b>[var.number_of_emails]</b></a><!--[onload;block=span;when [var.show_email_count]=1;comm]-->
              &nbsp;|&nbsp;
              <a href="inviteread.php">[var.lang_invites]&nbsp;<b>[var.number_of_invites]</b></a><!--[onload;block=span;when [var.show_invites_count]=1;comm]-->
              <!--[onload;block=div;when [var.loggedin]=1;comm]-->
            </div>
    Does that help?

  • #4
    New Coder
    Join Date
    Apr 2014
    Location
    Daytona Beach, FL
    Posts
    50
    Thanks
    0
    Thanked 1 Time in 1 Post
    Code:
    <form onsubmit="this.style.Display='none';this.style.visibility='hidden';">
    That will work, but you need to straighten up your spaghetti code.

  • #5
    New Coder
    Join Date
    Aug 2014
    Location
    Thessaloniki,Greece
    Posts
    40
    Thanks
    2
    Thanked 2 Times in 2 Posts
    Please, please clean up your code!!!!!

    Dont put <style> Inside your form!!!
    Put it, in a seperate file.

  • #6
    Regular Coder
    Join Date
    Feb 2008
    Posts
    128
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Can you show me how to
    "Put it, in a separate file"?
    thanks

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,965
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    Can somebody explain to me what this stuff (in red) has to do with PHP??
    Code:
              <a href="myaccount.php">[var.lang_my_account]</a>
              &nbsp;|&nbsp;
              <a href="members/[var.user_name]">[var.lang_my_profile]</a>
    Is this from some kind of PHP template? It *looks* like a completely different server side language that recognizes [var. as meaning something special.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,965
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    You just take all your <style> blocks and copy them, in order, without the <style> and </style> flags, into a text file (conventionally named with ".css" on the end of the name).

    Then, in your pages' <head> section, you just do
    Code:
    <link rel="stylesheet" type="text/css" href="nameOfYourFile.css" />
    You can put the file in another directory (also typically named "css") or it can even be on another server if you give the full path to the file in the href.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #9
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,077
    Thanks
    2
    Thanked 320 Times in 312 Posts
    [var.lang_my_account]
    ^^^ That's the syntax used by the template engine the OP's script (phpmotion) is using. Best I can tell, the var.somename refers to the php variable $somename.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,965
    Thanks
    79
    Thanked 4,429 Times in 4,394 Posts
    I guess it makes sense. But so does it make sense to enable short tags and then just use <?=$somevariable?> That's exactly the same number of characters as [var.somevariable]
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,077
    Thanks
    2
    Thanked 320 Times in 312 Posts
    The template engine (it's an OOP class) doesn't make much sense to me either. By allowing the template the ability to access any php variable present in the script, such as ones holding database connection credentials, it would allow exposing sensitive information that the template shouldn't have access to.

    The template engine should have enforced encapsulation by only allowing template data to be provided via class methods/properties. This would have also made using the template engine easier, since you wouldn't need to remember and keep track of what php variables are used in the general logic to prevent conflict with those that are used in the template.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #12
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,073
    Thanks
    11
    Thanked 98 Times in 96 Posts
    and possibly `var` is essentially doing that , I dont know which template engine is being used but in e.g. smarty your template can only display what it has been assigned ..
    PHP Code:
    ...
    $somevar='unavailable to smarty';
    $db_vars=db->fetch_assoc($some_query);

    $smarty=new Smarty();
    $smarty->assign('var',$array_of_vars);
    return 
    $smarty->fetch('your_tpl.tpl'); 
    Code:
    {$db_vars|print_r}
    {$db_vars.some_field}
    {$somevar}  << will error
    smarty does however allow you to access global constants and other globals {$smarty.SESSION.some_session_variable} .. which is good and bad
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #13
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,077
    Thanks
    2
    Thanked 320 Times in 312 Posts
    The following is the sum total code for rendering a template, from a previous thread from this OP where I looked into this -
    PHP Code:
    $template        "themes/$user_theme/templates/main_1.htm";
    $inner_template1     "themes/$user_theme/templates/search_results.htm";
    $TBS            = new clsTinyButStrong;
    $TBS->NoErr     true;

    $TBS->LoadTemplate("$template");

    if ( 
    $query_get_type == 'group_profile' $TBS->MergeBlock('blkfeatured'$mygroups); else $TBS->MergeBlock('blkfeatured'$result_search);

    $TBS->Render TBS_OUTPUT;
    $TBS->Show(); 
    The only data specifically being passed in is the $mygroups, and $result_search, which are result sets from queries. All the other var.variables..., like the var.lang_xxx (from a language definition file that gets included), var.loggedin, ... are php program variables that the template is causing the template engine to directly access.
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #14
    Regular Coder
    Join Date
    Feb 2008
    Posts
    128
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Old Pedant View Post
    You just take all your <style> blocks and copy them, in order, without the <style> and </style> flags, into a text file (conventionally named with ".css" on the end of the name).

    Then, in your pages' <head> section, you just do
    Code:
    <link rel="stylesheet" type="text/css" href="nameOfYourFile.css" />
    You can put the file in another directory (also typically named "css") or it can even be on another server if you give the full path to the file in the href.
    Thanks for your reply.
    I followed your instructions and put this in another file called loginForm.css:
    Code:
    .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-color:#e5e5e5;
    }
    }
    But by removing this styling code from the Form, how does the styling of .form_label have any way of effecting the Form?
    Please clarify. Thanks

  • #15
    Regular Coder
    Join Date
    Feb 2008
    Posts
    128
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Thanks for your suggestion.
    I added this:

    Code:
    <form onsubmit="this.style.Display='none';this.style.visibility='hidden';">
    at the end of this, without success:

    Code:
    <form action="../login.php" method="post" accept-charset="UTF-8" class="middletext">
    <p>
    <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" />
    
    &nbsp;<img src="http://codingforums.com/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" />
    <form onsubmit="this.style.Display='none';this.style.visibility='hidden';">
    </p>
    </form>
    Any other suggestions will be appreciated


  •  

    Posting Permissions

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