Board index   FAQ   Search  
Register  Login
Board index PHP Your Scripts

Session Problem -Need Help

This is where you share YOUR scripts with others

Moderators: macek, egami, gesf

Session Problem -Need Help

Postby saatchi » Tue Apr 03, 2012 10:10 am

Hi guys
<?php
//Start or resume a session
session_start();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>

<title>Movies Store</title>

<!-- CSS External LINKS -->
<link rel="stylesheet" rev="stylesheet" href="../styles/format.css" type="text/css" />
<link rel="stylesheet" rev="stylesheet" href="../styles/formatl.css" type="text/css" />





</script>

</head>

<body>

<div class="contian">
<div class="inner">

<div class="column one">
<a href="../index.html">Home</a> <a href="../index.html">Home</a> <a href="../index.html">Home</a>
<div class="inside">


<h2>Who are you</h2>
<?php


//If the "uname" session variable is not set or is empty, redirect to login page
if ( !isset($_SESSION['username']) || $_SESSION['username'] == '' )
{


echo '* <a href="view.php">View Stuff</a><br />';

exit;

}

echo '<p>Welcome, '.$_SESSION['username'].' ('.$_SESSION['access_level'].')</p>';
echo '<p>The '.$_SESSION['access_level'].' menu is below.</p>';

//Show appropriate menu based on access level session variable
if ( $_SESSION['access_level'] == 'admin' )
{
echo '* <a href="view.php">View Stuff</a><br />';
echo '* <a href="edit.php">Edit Stuff</a><br />';
echo '* <a href="delete.php">Delete Stuff</a>';
echo '<p><a href="logout.php">Log Out</a></p>';
}

if ( $_SESSION['access_level'] == 'member' )
{
echo '* <a href="view.php">View Stuff</a><br />';
echo '* <a href="edit.php">Edit Stuff</a>';
echo '<p><a href="logout.php">Log Out</a></p>';
}


?>

</div>
<div class="inside">
<h2>About Me</h2>
<p>sssssssssssssssssssssssssssssssa dffdmfdmn sdfmf,.mfsd,. sd,mf,.sdfm.,sdf </p>


</div>

</div>

<div class="column three">
<div class="navbar">

<p>Main Menu </p>
<a href="index.html">Home</a>
<hr />
<a href="index.html">About us</a>
<hr />
<a href="showlist.php">Movie List</a>
<hr />
<a href="index.html">Contact Us</a>
<hr />

<hr />
<div>
<form name="movie" action="foundmovie1.php" method="post">
<div>

<input type="text" name="moviename" size="20" maxlength="60" value="Find Movies" onfocus="if(!this._haschanged){this.value=''};this._haschanged=true;"/><input type="submit" value="Find" />
</div>
</form>
</div>
</div>
</div>

<div class="footer">CopyRight By Muhammad Saleem
<p>
<a href="http://validator.w3.org/check?uri=referer"><img
src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>

<br />
<a href="http://jigsaw.w3.org/css-validator/check/referer">
<img style="border:0;width:88px;height:31px"
src="http://jigsaw.w3.org/css-validator/images/vcss-blue"
alt="Valid CSS!" />
</a>
</p>

</div>

</div>
</div>
</body>
</html>


=========================
there are 3 level of access:
admin and memeber, also public visitors who can access without login .. however, my problem with public section :

//If the "uname" session variable is not set or is empty, redirect to login page
if ( !isset($_SESSION['username']) || $_SESSION['username'] == '' )
{


echo '* <a href="view.php">View Stuff</a><br />';

exit;

Wheni I PUT EXIT function , basically i can't see the main menu or footer and when i remove the exit function I CAN SEE the main menu and footer but there is an error message:
Notice: Undefined index: username in C:\Users\win7\Desktop\xampp\htdocs\PHP-A1-ver123\A1-PHP\pages\usermenu1.php on line 103

Notice: Undefined index: access_level in C:\Users\win7\Desktop\xampp\htdocs\PHP-A1-ver123\A1-PHP\pages\usermenu1.php on line 103

how can i fix it

Thankx
saatchi

}
saatchi
New php-forum User
New php-forum User
 
Posts: 1
Joined: Tue Apr 03, 2012 9:56 am

Return to Your Scripts

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron