Riddle me this.
I've built a site on a Linux server that's running Apache. I'm trying to move it over to a new location that's running iPlanet and Solaris.
My problem is with passing a session variable on my admin pages. When you hit any page from my admin area, it looks for a session variable. If it is not there, you are given a link to a page that validates your username and password from a database.
Thus the problem. On my validation page I put in a username and password, hit my submit button, the form is posted to the same page where you are supposed to see a message saying you're info was correct, click here to move on. Or a message saying you are incorrect and you need to try again.
Here is the code to my validation page. If anyone has any suggestions, pass em on.
<?php
session_start();
session_register("sess_var");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<head>
<title>Administration</title>
<link rel="STYLESHEET" type="text/css" href="main.css">
</head>
<body bgcolor="#000000">
<table bgcolor="#000000" border="0" width="100%" align="center">
<tr>
<td align="center" class="header"><b>Administration</b></td>
</tr>
</table>
<?php
if (!$HTTPS && $REQUEST_METHOD=="POST") {
// includes
include("conf.php");
include("functions.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
$sql = "SELECT id
FROM users
WHERE name='$name' and password='$password'";
$result = mysql_query($sql)
or die("Couldn't execute query.");
$num = mysql_numrows($result);
if ($num == 1) {
$sess_var = "Authorized User!";
echo "<p align=\"center\" class=text>You have been authorized!</p>";
echo "<p align=\"center\"><A HREF=\"index.php\">Click here to continue.</A></p>";
}
else {
echo "<p align=\"center\" class=text>You are <b>NOT</b> authorized to use this site or you have entered incorrect information for your username and password!</p>";
echo "<p align=\"center\"><A HREF=\"validate.php\">Click here to try again.</A></p>";
}
}
else {
?>
<form action="validate.php" method="post">
<table align="center" border="0" cellpadding="3" cellspacing="0" class="text">
<tr>
<td><strong>Username:</strong></td>
<td><input type="text" name="name" size="15"></td>
</tr>
<tr>
<td><strong>Password:</strong></td>
<td><input type="password" name="password" size="15"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
<?php
}
?>
</body>
</html>
Thanks a lot you crazy coding nutty fools you!