shane85 Posted August 13, 2009 Share Posted August 13, 2009 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] Quote Link to comment Share on other sites More sharing options...
phpwiz Posted August 13, 2009 Share Posted August 13, 2009 i didn't read your code into detail but what i did was make an if statement. if the user is logged in displayect ect. if not logged in display login form Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 13, 2009 Share Posted August 13, 2009 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. Quote Link to comment Share on other sites More sharing options...
shane85 Posted August 13, 2009 Author Share Posted August 13, 2009 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(); Quote Link to comment Share on other sites More sharing options...
shane85 Posted August 13, 2009 Author Share Posted August 13, 2009 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 Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 13, 2009 Share Posted August 13, 2009 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.. Quote Link to comment Share on other sites More sharing options...
shane85 Posted August 13, 2009 Author Share Posted August 13, 2009 HA! it works!! Thank you very much...again, this board is great...great members Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 13, 2009 Share Posted August 13, 2009 HA! it works!! Thank you very much...again, this board is great...great members No problem Be sure to mark this topic as solved, in the bottom left of the thread.. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.