Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refreshing Logoff info

Status
Not open for further replies.

Tuck007

Technical User
Apr 29, 2002
105
US
I feel a little silly. I love using PHP, but I think I may need a little javascript for this. I want one link to activate after a user has been verified and is in session. What I've constructed works, but it's not seemless and kinda gross, take a look:
Code:
1  <?php
2  session_start();
3  ?>
4  <title>Directory Info</title>
5  <link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;../includes/default.css&quot; />
6  <meta HTTP-EQUIV=&quot;Refresh&quot; content=&quot;7;url=header.php?PHPSESSID=<?php echo $PHPSESSID;?>&quot;>
7  </head>
8  <body>
9  <table border=&quot;0&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot; align=&quot;center&quot; width=&quot;661&quot;>
10   <tr> 
11     <td colspan=&quot;2&quot;><img src=&quot;../images/top.gif&quot; width=&quot;803&quot; height=&quot;26&quot;></td>
12   </tr>
13   <tr> 
14     <td colspan=&quot;2&quot;><img src=&quot;../images/shout_banner.gif&quot; width=&quot;803&quot; height=&quot;79&quot;></td>
15   </tr>
16 </table>
17 <center>
18 <table summary=&quot;&quot; width=&quot;640&quot;>
19 <tr>
20 <td align=&quot;center&quot;><h2>Secure Download Section</h2></td><td align=&quot;right&quot;>
21 <?php 
22 if (!session_is_registered('userid')){
23 	 echo 'Must Log On';
24 }
25 else{
26 		 echo '<a href=&quot;logout.php?PHPSESSID=', $PHPSESSID, '&quot; target=&quot;body&quot;>Log Off</a>';
27 		 }
28 ?>
29 </tr>
30 <tr>
31 </table>
32 </body>
33 </html>
[code]

Is there anything more simple one can do here? [B].:TUCK:.[/B]
 
Not sure what u want to do exacly

why dont u use header(Location..)

check if the session exists, if yes redirect him to the required page..

--------------------------------------------------------------------------
I never set a goal because u never know whats going to happen tommorow.
 
Using the
Code:
<meta http-EQUIV=&quot;Refresh&quot; content=&quot;7;url=header.php?PHPSESSID=<?php echo $PHPSESSID;?>&quot;>
, I am doing just that. I'm just refreshing the same page every 7 seconds. I'm usinf this refresh to check if the session is registered. When the session is not registered, &quot;Must Log On&quot; is displayed. When the session is regestered, a hyperlink that says, &quot;Log Off&quot; is displayed.
This is the header page. When the user enters a username and password in the body page, the session is started. I want the option to Log Off in the header, only when a user is logged in. .:TUCK:.
 
Why are you reloading the page every 7 seconds? Are you expecting that the user will be suddenly logged in without his intervention?


On every page that would require that the user be logged in, have it test for the presence of a session variable -- call it &quot;user_id&quot;. If the variable exists, the script runs. If not, the script sets a session variable called &quot;return_to&quot; which contains the url of the current page. Then it redirects the user to a login page.

The login page submits to itself. If the login form variables are present, it processes them. If not, it just outputs the form. When it processes the login form variables, and the credentials are good, it sets the session variable &quot;user_id&quot; and redirects the browser to the page that sent the user there -- the contents of &quot;return_to&quot; if that variable is set, some default page if not. If the form field variables are there and the credentials do not work, the script outputs an error and shows the form fields again.
______________________________________________________________________
TANSTAAFL!
 
That's a good suggestion, but not what I want to do. The header page, that contains the text I want to change when ht e user logs in is in a seperate page and frame. The login form is in it's own frame and so is all the content. I was hoping I could find a way to have the text in header frame change only when a user is logged in or out. Is there a way I can do that simply?
.:TUCK:.
 
If you are using framesets, you have two choices.

If you only want to reload those frames that need to change, you're going to have to use JavaScript.

Otherwise, all your forms will need to submit to a PHP script which is the source for your frameset. ______________________________________________________________________
TANSTAAFL!
 
I'd like to use a javascript. Should I close this thread and start another in the Javascript forum? .:TUCK:.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top