login script to blank page
Posted: Wed Dec 22, 2004 6:43 pm
can anyone see anything wrong with this?
submiting to a blank page??
submiting to a blank page??
Code: Select all
<?php
$username = $_POST["username"];
$password = $_POST["password"];
if(!empty($_POST['submit']))
{
mysql_connect('localhost','chris','survey') or die ("Could not connect to database");
mysql_select_db('survey') or die ("Could not select database!" .mysql_error());
$sql = "select * from tbl_admin where a_username = '$username'";
$result = mysql_query($sql) or die("Execution failed: ".mysql_error());
while ($row=mysql_fetch_array($result))
{
if ($row["a_password"] == $_POST["password"])
{
echo"wrong passwrod";
$_SESSION["name"] = $username;
$_SESSION["loggedin"] = "set";
}
else
{
echo "wrong password";
}
}
}
?>Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<style type="text/css" media="all">
@import "/css/survey.css";
</style>
<script language="JavaScript" type="text/JavaScript">
function Login()
{
var errors = false;
if (window.document.login.username.value == '')
{
alert("Username is a required field.");
window.document.login.username.focus(); return (false); errors = true;
}
if (window.document.login.password.value == '')
{
alert("Password is a required field.");
window.document.login.password.focus(); return (false); errors = true;
}
if (errors == false)
{
document.login.submit();
}
}
</script>
</head>
<body>
<form name="login" action="<?echo $PHP_SELF?>" method="post">
<div id="main_container">
<div id="container">
<img src="/images/login_logo.gif" height="101" width="150" alt="login_logo" class="login_logo" />
<div id="login">
<p>
<table>
<tr>
<td>Username:</td>
<td><input name="username" id="username" type="text" class="inputtext"/></td>
</tr>
<tr>
<td>Password:</td>
<td><input name="password" id="password" type="password" class="inputtext" /></td>
</tr>
<tr>
<td colspan="2" align="right"><input name="login" type="button" value="Login" class="inputbutton" onClick="javascript:Login();"/></td>
</tr>
</table>
</p>
</div>
</div>
</div>