shakim
02-13-2008, 04:05 AM
We moved our web server to a new machine with the following config.
Apache 2
MySQL 5
PHP 5
SUSE Linux
Everything works fine. The php pages show up fine. The record sets all show up. But when I go to login in an admin page. I put in the username and password and click login. Nothing happens when I click the login button except the fields clear. Also the same thing happens when I try to input something in the search field. Nothing happens. I read somewhere that it has something to do with the session module? My session module is turned on. I tried using error reporting
Turn on error reporting:
PHP Code:
ini_set('display_errors', 1);
error_reporting(E_ALL);
But when I run the page the entire page is a blank.
Any thoughts?
alexjewell
02-17-2008, 03:19 AM
Even if this page originally used to work, it may still be an issue in the code itself. Paste the page's code and/or login script.
shakim
02-19-2008, 06:05 PM
Here is the code. Thanx for the help in advanced.
<?php session_start(); ?>
<?php ob_start(); ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Cache-Control: private");
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php include ("db.php") ?>
<?php include ("phpmkrfn.php") ?>
<?php
// User levels
define("ewAllowAdd", 1, true);
define("ewAllowDelete", 2, true);
define("ewAllowEdit", 4, true);
define("ewAllowView", 8, true);
define("ewAllowList", 8, true);
define("ewAllowReport", 8, true);
define("ewAllowSearch", 8, true);
define("ewAllowAdmin", 16, true);
if (@$HTTP_POST_VARS["submit"] <> "") {
$bValidPwd = false;
// Setup variables
$sUserId = @$HTTP_POST_VARS["userid"];
$sPassWd = @$HTTP_POST_VARS["passwd"];
if (!($bValidPwd)) {
$conn = phpmkr_db_connect(HOST, USER, PASS, DB, PORT);
$sUserId = (!get_magic_quotes_gpc()) ? addslashes($sUserId) : $sUserId;
$sSql = "SELECT * FROM `admin_users`";
$sSql .= " WHERE `username` = '" . $sUserId . "'";
$rs = phpmkr_query($sSql,$conn) or die("Failed to execute query: " . phpmkr_error() . '<br>SQL: ' . $sSql);
if (phpmkr_num_rows($rs) > 0) {
$row = phpmkr_fetch_array($rs);
if (strtoupper($row["password"]) == strtoupper($sPassWd)) {
$HTTP_SESSION_VARS["warren_status_User"] = $row["username"];
$HTTP_SESSION_VARS["warren_SysAdmin"] = 0; // non System Administrator
$bValidPwd = true;
}
}
phpmkr_free_result($rs);
phpmkr_db_close($conn);
}
if ($bValidPwd) {
// Write cookies
if (@$HTTP_POST_VARS["rememberme"] <> "") {
setCookie("warren_userid", $sUserId, time()+365*24*60*60); // change cookie expiry time here
}
$HTTP_SESSION_VARS["warren_status"] = "login";
ob_end_clean();
header("Location: index.php");
exit();
} else {
$HTTP_SESSION_VARS["ewmsg"] = "Incorrect user ID or password";
}
}
?>
<?php include ("header.php") ?>
<script type="text/javascript" src="ew.js"></script>
<script type="text/javascript">
<!--
function EW_checkMyForm(EW_this) {
if (!EW_hasValue(EW_this.userid, "TEXT" )) {
if (!EW_onError(EW_this, EW_this.userid, "TEXT", "Please enter user ID"))
return false;
}
if (!EW_hasValue(EW_this.passwd, "PASSWORD" )) {
if (!EW_onError(EW_this, EW_this.passwd, "PASSWORD", "Please enter password"))
return false;
}
return true;
}
//-->
</script>
<p><span class="phpmaker">Login Page</span></p>
<?php
if (@$HTTP_SESSION_VARS["ewmsg"] <> "") {
?>
<p><span class="phpmaker" style="color: Red;"><?php echo $HTTP_SESSION_VARS["ewmsg"]; ?></span></p>
<?php
$HTTP_SESSION_VARS["ewmsg"] = ""; // Clear message
}
?>
<form action="login.php" method="post" onSubmit="return EW_checkMyForm(this);">
<table border="0" cellspacing="0" cellpadding="4">
<tr>
<td><span class="phpmaker">User Name</span></td>
<td><span class="phpmaker"><input type="text" name="userid" size="20" value="<?php echo @$HTTP_COOKIE_VARS["warren_userid"]; ?>"></span></td>
</tr>
<tr>
<td><span class="phpmaker">Password</span></td>
<td><span class="phpmaker"><input type="password" name="passwd" size="20"></span></td>
</tr>
<tr>
<td> </td>
<td><span class="phpmaker"><input type="checkbox" name="rememberme" value="true">Remember me</span></td>
</tr>
<tr>
<td colspan="2" align="center"><span class="phpmaker"><input type="submit" name="submit" value="Login"></span></td>
</tr>
</table>
</form>
<br>
<p><span class="phpmaker">
</span></p>
<?php include ("footer.php") ?>
alexjewell
02-22-2008, 12:44 AM
Well, you may want to use the newer $_POST variable instead of $HTTP_POST_VARS.
I'd also add some echo statements in there to see where the problem is. Maybe add some else statements and what not. Basically, echo with every if/else if/else statement saying "this is happening" or "this is true" or "this is not true", but be specific so you can find out exactly what is not working. This will allow you to narrow in on the problem to a specific area of the code.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.