Jump to content

Recommended Posts

hey I swirched over to a xampp server and the page1/page2.php thing is working...

 

but one more question..

 

now i want my thing to be like this..

 

if it's a guest he'll see the login username/password text field below which are in body.php which is included in the index file..

 

if he logs in successfully the login username/password field should not be appear..

 

well i tried many session stuff but I'm still unsuccessfull.. ;D

 

and also include a link on header.php file which directs to logout only for successfully logged in members...guest can't view it ;D

 

any suggestions and a simple solution;D

Well to show the login to the guest but not to someone who is logged in you would need an if statement.

 

You would want to check if the session isn't set. If it's not set, then show the login form. Think about it. ;)

Well to show the login to the guest but not to someone who is logged in you would need an if statement.

 

You would want to check if the session isn't set. If it's not set, then show the login form. Think about it. ;)

 

hey man i did the same thing but it doesn't work... :(

it gives some error :(

Please post what you did, along with the error. It'll help us help you. :)

 

hey

 

it works like...wen u login it directs to login.php where ur account is verified and then it echoes succesfull login and in login.php a session is setted..

 

then i put session_start(); in the index.php and the if statement

 

then error given on index.php is

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\new\index.php:3) in C:\xampp\htdocs\new\index.php on line 4

 

the forth line in index.php is session_start();

session_start() should always be at the top.

 

Okay... Here is some sample code.

 

//call session_start() up at the very top of the page, ABSOLUTE TOP!

//Now lets check if the session isn't set.
if(!isset($_SESSION['user_logged_in_session'])){
//Okay, the session isn't set. That means it must be a guest.
echo "Show the login form!";
}else{
//Hey, it's a member!
echo "Welcome back member!";
}

session_start() should always be at the top.

 

Okay... Here is some sample code.

 

//call session_start() up at the very top of the page, ABSOLUTE TOP!

//Now lets check if the session isn't set.
if(!isset($_SESSION['user_logged_in_session'])){
//Okay, the session isn't set. That means it must be a guest.
echo "Show the login form!";
}else{
//Hey, it's a member!
echo "Welcome back member!";
}

 

Ok now on logging in it says welcome back member...

 

but now wat about logout?

 

I tried these codes for logout

 

<?php
session_start();

session_destroy;


include "header.php";
if(!isset($_SESSION['user_logged_in_session']))
{
Echo "<h3><center>You are logged out.</h3></center>";
Echo "<br><center><h3>Click <a href=index.php>here</a> to goto index page</h3></center>";
header("location:index.php");
}
Else
{
Echo "not logged out";
};

?>

 

and it everytimes echoes not logged out and the session isn't destroyed :(

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.