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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing text when a session is started 1

Status
Not open for further replies.

Tuck007

Technical User
Apr 29, 2002
105
US
I use PHP to start a session when users log in. I'd like an option to log off to appear when the session is started. Is there a simple way to do this? .:TUCK:.
 
Actually, that didn't sound very helpful did it?
If you know your php but just don't know the Javascript then this should give you an idea of the javascript you need to activate a button or something to give the option.
This is a button to show log off option. Normal HTML to show wherever you will need it.

Code:
<input type=&quot;button&quot; value=&quot;Log Off&quot; style=&quot;display:none&quot; id=&quot;theBtn&quot;>

and this javascript function will show the button if you can call it however you need to.
Code:
function DisplayIt(){
  document.getElementById(&quot;theBtn&quot;).style.display=&quot;block&quot;;
}
Hope I helped / Thanks for helping
if ((x<10&&y<10) &&(((parseInt(x.toString()+y.toString())-x-y)%9)!=0)){ alert(&quot;I'm a monkey's uncle&quot;); }
 
I started in the PHP forum. I been doing a lot with PHP, but never dabbled in javascript that much.
I think I understand. I could put the trigger in my PHP if statement. It would look like this I believe:
Code:
if ($auth == &quot;1&quot;) {
    if (!session_is_registered('userid')) {
         $access = $data_pair[2];
         session_register(&quot;access&quot;);
         $userid = $username;
         session_register(&quot;userid&quot;);
    echo '<meta http-EQUIV=&quot;Refresh&quot; content=&quot;5;url=user_check.php?PHPSESSID=', $PHPSESSID, '&quot;>';
    echo 'function DisplayIt(){
  document.getElementById(&quot;theBtn&quot;).style.display=&quot;block&quot;;
}';
    echo '<center>Acces level of: ', $access, '. Loading in 5 seconds. <a href=&quot;user_check.php?PHPSESSID=', $PHPSESSID, '&quot;>Click here to continue</a> if not automatically done.</center>';
    exit;
    }
And can I put this into another page:
Code:
<a id=&quot;theBtn&quot; href=&quot;logout.php?PHPSESSID=', $PHPSESSID, '&quot; target=&quot;body&quot;>Log Off</a>
Think it would work?
.:TUCK:.
 
Well, I don't know PHP, but:
If you want the log off link to be hidden to start with you still need style=&quot;display:none&quot; in the tag.
It won't display the link when the function is called from another page. The function needs to be on the same page as the link itself.
But why not give it a go and let us know? Maybe we can work from there.

Hope I helped / Thanks for helping
if ((x<10&&y<10) &&(((parseInt(x.toString()+y.toString())-x-y)%9)!=0)){ alert(&quot;I'm a monkey's uncle&quot;); }
 
Found this in another thread:
Code:
        <form id=&quot;frm&quot;>
            <textarea ID=&quot;values&quot; NAME=&quot;values&quot;>Hello</textarea>
        <script language=&quot;javascript&quot;>
        setcontent();
        function setcontent() {
         try {
                parent.frames.item('content').eval('showcontent(\'' + escape(String(frm.values.value)) + '\')');
         }
         catch(errorObject) {
            setTimeout('setcontent()', 500);
         }
        }
        </script>
I'm going to try a variation of this in to trigger the display function. I'll let you know. .:TUCK:.
 
Here is the function I have created:
Code:
<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
<!--
function logOff(){
parent.frames.item('header').getElementById(&quot;logOff&quot;).style.display=&quot;block&quot;;
}
//-->
</script>
<center><img src=&quot;img/blnkpxl.jpg&quot; onLoad=logOff() alt=&quot;Login Complete&quot;><br>
Acces level of: <?php echo $access; ?>. Loading in 5 seconds. <a href=&quot;user_check.php?PHPSESSID=<?php echo $PHPSESSID ?>&quot;>Click here to continue</a> if not automatically done.</center>

This is what I have in the target page:
Code:
<tr>
<td align=&quot;center&quot;><h2>Secure Download Section</h2></td><td align=&quot;right&quot; id=&quot;logOff&quot; style=&quot;display:none&quot;>
<?php 
//--if (!session_is_registered('userid')){
//--	 echo 'Must Log On';
//--}
//--else{
		 echo '<a href=&quot;logout.php?PHPSESSID=', $PHPSESSID, '&quot; target=&quot;body&quot;>Log Off</a>';
//--		 }
?>
</tr>

I don't know if I am calling the object correctly. It's not working. Any suggestions? .:TUCK:.
 
Finally got it to work:
Code:
<?php
if ($auth == &quot;1&quot;) {
			if (!session_is_registered('userid')) {
				 $access = $data_pair[2];
				 session_register(&quot;access&quot;);
				 $userid = $username;
				 session_register(&quot;userid&quot;);?>
			<meta HTTP-EQUIV=&quot;Refresh&quot; content=&quot;5;url=user_check.php?PHPSESSID=', $PHPSESSID, '&quot;>
			</head>
			<body>
			<script language=&quot;JavaScript&quot; type=&quot;text/javascript&quot;>
			<!--
			function logOff(){
							 parent.frames.item('header').document.getElementById(&quot;logOff&quot;).style.display=&quot;block&quot;;
			}
			//-->
			</script>
			<center><img src=&quot;img/blnkpxl.jpg&quot; onLoad=&quot;logOff()&quot; alt=&quot;Login Complete&quot;><br>
			Acces level of: <?php echo $access; ?>. Loading in 5 seconds. <a href=&quot;user_check.php?PHPSESSID=<?php echo $PHPSESSID ?>&quot;>Click here to continue</a> if not automatically done.</center>
			<?php
			exit;
			} else {
			session_start();
			echo '<meta HTTP-EQUIV=&quot;refresh&quot; content=&quot;5;url=user_check.php?PHPSESSID=', $PHPSESSID, '&quot;>';
			echo '<center>Login has already been authorized. Automatic refrech will occur in 5 seconds. <a href=&quot;user_check.php?PHPSESSID=', $PHPSESSID, '&quot;>Click here to continue</a> if not automatically done.';
			exit;
			}
?>
The script was able to successfully make the change that I wanted in another page, that displayed in another frame. .:TUCK:.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top