I'm sure this is something simple and stupid, but I need a fresh pair of eyes on it since I can't get it to work. It gives me a blank HTML page under the address checklogin.php instead of going to home.php like it's supposed to. The returned page is blank -- no error, no nothing -- no matter whether I type in the correct username and password, incorrect, or even submitting nothing in the form fields.
I'm reworking a (formerly working) login script. Here's the form:
HTML Code:
<form action="checklogin.php" method="post">
<table width="600" border="0" align="center" cellpadding="3" cellspacing="0">
<tr>
<td align="right" valign="middle">Username:</td>
<td align="left" valign="middle"><input name="myusername" type="text" id="myusername" /></td>
</tr>
<tr>
<td align="right" valign="middle">Password:</td>
<td align="left" valign="middle"><input name="mypassword" type="password" id="mypassword" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit"value="LOGIN" /></td>
</tr>
</table></form>
Here's where the form goes (checklogin.php):
PHP Code:
<?php
include('includes/connect.php');
$sql="SELECT * FROM users WHERE username='$myusername'";
$result=mysql_query($sql);
$row = mysql_fetch_array($result);
if (!$row['username']) {
echo("Incorrect username . . . click <a href=\"index.php\">here</a> to try again.");
}
else if ($row['password'] != $mypassword) {
echo("Incorrect password for username ".$row['username']." . . . click <a href=\"index.php\">here</a> to try again.");
}
else {
session_start();
$_SESSION['sess_username'] = $row['username'];
$_SESSION['level_display'] = $row['userlevel'];
header("location:home.php");
}
?>
And here's the include (connect.php):
PHP Code:
<?php
$dbhost = 'hostinfo';
$dbuser = 'username';
$dbpass = 'password';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'databasename';
mysql_select_db($dbname);
or die("Select DB Error:".mysql_error());
?>
Any thoughts would be appreciated.