Ok here's my code
<?php
$authorized = FALSE;
if ( (isset($_SERVER['PHP_AUTH_USER']) AND isset($_SERVER['PHP_AUTH_PW'])) ) {
define ('username', 'hitoshi_admin');
define ('password', '*****');
define ('localhost', 'localhost');
define ('sitename', 'www.PSOrevolution.com');
$dbc = @mysql_connect (localhost, hitoshi_admin, *****) OR die ('Could not connect to MySQL: ' . mysql_error() );
mysql_select_db (hitoshi_web) OR die ('Could not select the database: ' . mysql_error() );
$query = "SELECT first_name FROM users WHERE username='{$_SERVER['PHP_AUTH_USER']}' and password=PASSWORD('{$_SERVER['PHP_AUTH_PW']}')";
$result = mysql_query ($query);
$row = @mysql_fetch_array ($result);
if ($row) { $authorized = TRUE;
}
}
if (!$authorized) {
header('WWW-Authenticate: Basic realm="Log in to experiance PSO Revolution, where two worlds collide!"');
header('HTTP/1.0 401 Unauthorized');
echo '
<html>
<head>
<title>Signup Form</title>
</head>
<body>
<form name=form1 method=post action=register.php>
<table width=100% border=0 cellpadding=4 cellspacing=0>
<tr>
<td width=24% align=left valign=top>First Name</td>
<td width=76%><input name=first_name type=text id=first_name2></td>
</tr>
<tr>
<td align=left valign=top>Last Name</td>
<td><input name=last_name type=text id=last_name></td>
</tr>
<tr>
<td align=left valign=top>Email Address</td>
<td><input name=email_address type=text id=email_address></td>
</tr>
<tr>
<td align=left valign=top>Desired Username</td>
<td><input name=username type=text id=username></td>
</tr>
<tr>
<td align=left valign=top>Information about you:</td>
<td><textarea name=info id=info></textarea></td> </tr>
<tr>
<td align=left valign=top> </td>
<td><input type=submit name=Submit value=Join Now!></td>
</tr>
</table>
</form>
</body>
</html>
';
exit;
}
?>
<body bgcolor="00000" text="ffffff">
<center>
<font face="arial" size="0">
Welcome,
<?php
echo "{$_SERVER['PHP_AUTH_USER']}";
?><br>
Authenticated!<br>
Please proceed, <a href="login_success.php">to the members section.</a>
</center>
This logs the user in.. but when I go to the next page, it appears like it never even logged in.. Here's the next page (login_success.php) :
<?
session_start();
include 'mysql_connect.php';
echo "Welcome, ". $_SESSION['username'] ." ";
echo "<h3><b>News</b></h3>";
include 'news.php';
echo "<h3><b>Admin:</b></h3>";
include 'admin.php';
if ($_SESSION['username'] == "Hitoshi" ) {
echo "<li><a href=news.php>News</a>";
}
if ($_SESSION['username'] == "Hitoshi" ) {
echo "<li><a href=admin.php>Admin</a>";
}
echo "<b><a href=logout.php>Logout</a>";
print "";
?>
What it does is.. doesnt come up with the username in "WELCOME USERNAME" and doesnt give access
if ($_SESSION['username'] == "Hitoshi" ) {
echo "<li><a href=news.php>News</a>";
}
if ($_SESSION['username'] == "Hitoshi" ) {
echo "<li><a href=admin.php>Admin</a>";
}
Therefor, it's obvious that the session is not running properly..
Any ideas?
I have been trying to do this login thing for weeks, this is the closest ive got. plz help.. 😕