here is my code,u only have to care for the session part:
this is the login page:
<?php
session_start();
$adminname = "emad";
$serverpassword = "omda";
$servername = "localhost";
$dbname = "mall";
$sql = "SELECT * FROM registration WHERE username = '$username' and
password='$password'";
if($username != ""):
$conn = mysql_connect($servername, $adminname, $serverpassword);
mysql_select_db($dbname, $conn);
$result = mysql_query($sql, $conn);
if(@mysql_num_rows($result) != 0)
{
$row = mysql_fetch_array($result);
$valusername = $username;
session_register("valusername");
mysql_close($conn);
header("location:http://$HTTP_HOST/mall/menu.php");
exit();
}
else
{
echo "<h2>Sorry,you entered either a wrong User Name or Password.</h2>Try
again<BR>";
echo "<a href='login.php'>Back</a>";
}
else:
?>
<html>
<head>
<title>Login Page</title>
</head>
<body background="o3b.gif" onLoad="document.myForm.username.focus();">
<FONT color="#fdf8db">
<table>
<form name="myForm" method="post" action="login.php">
<tr><td align="right"><FONT color="#fdf8db"><b>User Name</b><td><input type="text"
name="username" size="40">
<tr><td align="right"><FONT color="#fdf8db"><b>Password</b><td><input type="password"
name="password" size="40">
<tr><td colspan="2" align="center"><input type="Submit" value="Login">
</form>
<tr><td><a href="forgetpass.php"><FONT size="-1">Forgot your password?</a>
</table>
</body>
</html>
<?php
endif;
?>
and now this is the menu page(when login is correct):
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META name="GENERATOR" content="IBM WebSphere Homepage Builder V5.0.1 for Windows">
<TITLE>Cocktail bar</TITLE>
</HEAD>
<?php
<?php
session_start();
if(!(session_is_registered("valusername")))
{
header("Location:http://$HTTP_HOST/mall/login.php");
exit();
}
?>
?>
<BODY link="#99ff00" vlink="#99cc66" alink="#ffff00">
<TABLE border="1" width="100%" height="100%">
<TBODY>
<TR>
<TD height="298" width="591"></TD>
<TD height="298" rowspan="2" background="blue5b.gif" width="158" valign="middle"
align="center"><A href="add.php"><FONT color="#ffffff">Add</FONT></A><FONT
color="#ffffff"><BR>
<A href="delete.php">Delete</A><BR>
</FONT><A href="update.php"><FONT color="#ffffff">Update</FONT></A><BR>
<A href="editinfo.php">Edit you Info</A></TD>
</TR>
<TR>
<TD height="12" width="591"></TD>
</TR>
</TBODY>
</TABLE>
</BODY>
</HTML>
when i login and i'm in the menu page this error show:
Warning: Cannot add header information - headers already sent by (output started at
C:\apache\htdocs\mall\menu.php:7) in C:\apache\htdocs\mall\validate.php on line 4
can anyone help?
------------------------------------------------------------
------------------------------------------------------------
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]