Hello there, I have my sign in working to a degree. I click on sign in on my index.php page then that brings up a form which you enter your user id and password hit sign in and then it calls the sign-in-process.php script which checks for a match and then sends you back to index.php page which is all good but when you go back to the index.php you should have a different type of menu bar at the top of the screen, it does not change. What am I doing wrong?
Here is the three files:
index.php
<head>
<style type="text/css">
body {background-color:black;color:yellow;}
div.Search
{
margin-top: 15%;
margin-left: 25%;
margin-right: 25%;
margin-bottom: 20%;
}
div.Main_Logo
{
}
p.site_name
{
text-align: center;
font-size: x-large;
}
input.search
{
background-color: black;
text-align: center;
}
</style>
</head>
<body>
<?php
session_start();
if(isset($_SESSION[ "userid" ]))
{
echo "Welcome $userid <a href='account_settings.php'>Account Settings</a> | <a href='sign_out_process.php'>Sign Out</a>";
}
else
{
echo $_SESSION["userid"];
echo"Welcome Guest! <a href='sign-in.php'>Sign-In</a> | <a href='create-account.php'>Create Account</a>";
}
echo '
<div class="Search">
<div class="Main_Logo">
<p class="site_name">Disability Info Seek</p>
</div>
<center>
<form action="search.php" method="post">
<input class="search" type="text" name="search" size="50" /><br />
<input type="submit" name="Search" value="search" /><input type="submit" name="Advance Search" value="advance_search" />
</center>
</div>
';
?>
sign-in.php
<head>
<style type="text/css">
body {background-color:black;color:yellow;}
input.search
{
background-color: black;
text-align: center;
}
</style>
</head>
<body>
<?php
echo '
<div class="sign-in-container">
<center>
<form action="sign-in-process.php" method="post">
<label for="userid">User ID:</label><br />
<input class="sign-in-form" type="text" name="userid" size="25" /><br />
<label for="password">Password:</label><br />
<input class="sign-in-form" type="password" name="password" size="25" /><br />
<input type="submit" name="sign-in" value="Sign-In" /><input type="reset" name="clear" value="Clear" />
</form>
</center>
</div>
';
?>
sign-in-process.php
<?php
ini_set('display_errors', 'ON');
ini_set('error_reporting', E_ALL | E_STRICT );
session_start();
include '/home/dev/www/lib/db_config_cr-dev.php';
include '/home/dev/www/lib/db_conn-select.php';
// username and password sent from signup form
$userid = $_POST['userid'];
$password = $_POST['password'];
// $level = $_POST['level'];
// $encrypted_password = md5($password);
$query_s = "SELECT * FROM user WHERE user_id = '$userid' AND user_password = '$password' ";
$result_s = mysql_query($query_s) OR die("Sorry". mysql_error());
$record = mysql_fetch_array($result_s);
$count = mysql_affected_rows();
// If result matched $userid and $password, table row must be 1 row
if($count == 1)
{
// Register $userid, $password and redirect to file "index.php"
session_register("userid");
// session_register("level");
header("location:index.php");
}
else
{
echo "Wrong Username or Password";
}
mysql_close($conn);
?>
Sincerely,
Christopher