Jump to content

[SOLVED] hiding login/pass boxes once logged in HELP


shane85

Recommended Posts

I just want to say thanks in advance...this website has been EXTREMELY helpful in getting me through everything...im new to this but quickly learning and agian, thnx in advance.

 

I have attatched an image of my login/pass fields....the html is as follows

 

<div id="login_box">

 

<form id="loginForm" name="loginForm" method="post" action="login-exec.php">

   

    <fieldset>

        <p>Username:</p>

            <input type="text" id="user"  class="png_bg"/>

        </fieldset>

       

        <fieldset>

        <p>Password:</p>

            <input type="password" id="pass" class="png_bg" />

        </fieldset>

        <fieldset>

        <button id="login_btn" type="submit"></button>

        </fieldset>

       

</form>

<!--#login--></div>

 

very straight forward... what I would like to do is once the user is logged in and the session is created, to kill that text...I had a website done in the past which used a template file and I was able to put a tag before the above html like

 

<!-- BEGIN login -->

 

and after i twas done, end it with

 

<!-- END login -->

 

it was very easy and straight forward...what would the best way to achieve this be without using this template file? Basically I want it so when a user is logged in, the login fields arent there to see, or to re-login...might as well just take them out

 

thanks again

 

[attachment deleted by admin]

Link to comment
Share on other sites

I'm sure what every website does (atleast mine), uses PHP to echo the box in the first place.. roughly like..

 

if ($SESSION['loggedin'] == false) { 
echo '<input type="textarea">blaa</input>';// Whatever HTML your login form has
} else {
  echo "You are logged in as <b>".$SESSION['login_name']." <a href=\"logout.php\">log out</a></b>"
}

 

.. So it'd only appear when they're not logged in.

Link to comment
Share on other sites

oni-kun - thanks alot for reply to both of my threads...your going above and beyond! hate to bug you again, I tried it, and have it displayed like so in the login_include file

 

<?php

 

if ($SESSION['loggedin'] == false) {

echo '

 

<div id="login_box">

    <form id="loginForm" name="loginForm" method="post" action="login-exec.php">

   

    <fieldset>

        <p>Username:</p>

            <input name="login" type="text" class="png_bg" id="login" />

        </fieldset>

       

        <fieldset>

        <p>Password:</p>

    <input name="password" type="password" class="png_bg" id="password" />

        </fieldset>

        <fieldset>

        <button id="login_btn" type="submit"></button>

        </fieldset>

       

    </form>

</div>

 

';// Whatever HTML your login form has

} else {

  echo ""; // if its logged in, I dont want it to display anything in this area

}

 

but what I log in, it is still there...what do I need to include in my login script for this to work? I have included a snipit from my login script that registers variables into the session....what do I need to change? again...thank you

 

session_regenerate_id();

$member = mysql_fetch_assoc($result);

$_SESSION['SESS_LOCATION_ID'] = $member['location_id'];

$_SESSION['SESS_COMPANY_NAME'] = $member['company_name'];

$_SESSION['SESS_ADDRESS'] = $member['address'];

$_SESSION['SESS_CITY'] = $member['city'];

$_SESSION['SESS_PROVINCE'] = $member['province'];

$_SESSION['SESS_POSTAL_CODE'] = $member['postal_code'];

$_SESSION['SESS_FIRST_NAME'] = $member['contact_firstname'];

$_SESSION['SESS_LAST_NAME'] = $member['contact_lastname'];

$_SESSION['SESS_CONTACT_PHONE'] = $member['contact_phone'];

$_SESSION['SESS_CONTACT_EMAIL'] = $member['contact_email'];

$_SESSION['SESS_COMPANY_LOGO'] = $member['company_logo'];

$_SESSION['SESS_TICKER'] = $member['ticker'];

session_write_close();

header("location: venue.php");

exit();

Link to comment
Share on other sites

I SOMEWHAT got it to work...it takes it out....I have it like

 

<?php

 

if ($SESSION['$_SESSION['SESS_LOCATION_ID']' == false) {

echo '

 

<div id="login_box">

    <form id="loginForm" name="loginForm" method="post" action="login-exec.php">

   

    <fieldset>

        <p>Username:</p>

            <input name="login" type="text" class="png_bg" id="login" />

        </fieldset>

       

        <fieldset>

        <p>Password:</p>

    <input name="password" type="password" class="png_bg" id="password" />

        </fieldset>

        <fieldset>

        <button id="login_btn" type="submit"></button>

        </fieldset>

       

    </form>

</div>

 

';// Whatever HTML your login form has

} else {

  echo ""; // if its logged in, I dnot want it to display anything in this area

}

 

?>

 

 

but am getting this error

 

Parse error: syntax error, unexpected T_STRING, expecting ']' in /home/content/website/_include_login.php on line 3

Link to comment
Share on other sites

That works great, you did a simple error there though..

This:

if ($SESSION['$_SESSION['SESS_LOCATION_ID']' == false) {

Needs to be changed into:

if (!isset($_SESSION['SESS_LOCATION_ID'])) {

? You seemed to have accidentally nested invalid sessions,  but 'a'b'c'd' would show as an error, quote wise.

isset() should be as well instead of '==false'.. !isset() would mean if not set, aka not in the session..

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.