My web hosting provider says he doesn't believe PHP sessions are available to us at this time.
However, I tried it out and I'm having some luck with them. Sort of. When I 'bookmark' a site and double-click, I am redirected to the login page. However, if I drop down in my history in my browser and choose, I am able to get in! Where am I going wrong?
Here is the code thus far:
<?php
session_start();
if (!session_is_registered ("logged_in")) {
$logged_in = 0;
session_register ("logged_in");
} else {
$logged_in = 1;
}
if ($logout) {
$logged_in = 0;
}
include('../display.php');
?>
<BR>
<?
if ($submit) {
$db=mysql_connect("localhost","someusername","somepassword") or die ("Can't connect:" . mysql_error());
mysql_select_db("wowcorp",$db) or die ("Can't select database.");
$result=mysql_query("select * from users where username='".$username."'",$db) or die ("cant do it");
while ($row=mysql_fetch_array($result)) {
if ($row["password"]==$password) {
//LOGGED IN
session_register ("logged_in");
echo("<meta http-equiv=\"Refresh\" content=\"0;url=$PHP_SELF?goto=login\">");
} else {
printf("Incorrect password. Try again.");
}
}
}
switch ($goto)
{
case "login":
if( $logged_in == 0 ) {
echo("<meta http-equiv=\"Refresh\" content=\"0;url=$PHP_SELF\">");
} else {
head('Employee Login - Welcome','38','45');
include "welcome.php";
}
break;
case "corpdir":
if( $logged_in == 0 ) {
echo("<meta http-equiv=\"Refresh\" content=\"0;url=$PHP_SELF\">");
} else {
//head('Employee Login - Corporate Directory','38','40');
include "welcome-corpdir.php";
}
break;
case "emp":
if( $logged_in == 0 ) {
echo("<meta http-equiv=\"Refresh\" content=\"0;url=$PHP_SELF\">");
} else {
//head('Employee Login - Employee Forms','38','39');
include "welcome-emp.php";
}
break;
case "useful":
if( $logged_in == 0 ) {
echo("<meta http-equiv=\"Refresh\" content=\"0;url=$PHP_SELF\">");
} else {
//head('Employee Login - Useful Websites','38','41');
include "welcome-useful.php";
}
break;
default:
head('Employee Login','38','0');
?>
<form method="post" action="<?=$PHP_SELF?>">
<table width="309" border="0" cellspacing="0" cellpadding="5" align="CENTER" bgcolor="#e2e2e2">
<tr>
<td width="124" class="bodytext"><strong>Username :</strong></td>
<td width="356"><input name="username" type="text" id="username" size="20"></td>
</tr>
<tr>
<td class="bodytext"><strong>Password :</strong></td>
<td><input type="password" name="password" size="20"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" value="Sign On"></td>
</tr>
</table>
<p></p>
</form>
<?php
} // end of SWITCH statement
foot();
?>