animyst
03-23-2003, 07:28 PM
Ive created a login page that looks like so
login.php
<?php
session_start();
session_register('auth');
session_register('logname');
include("dbinfo.inc");
switch (@$do)
{
case "login";
$connection = mysql_connect($host, $user, $password)
or die ("Couldn't connect to the server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database");
$sql = "SELECT loginName from Member
WHERE loginName='$fusername'";
$result = mysql_query($sql)
or die ("Couldn't execute query.");
$num = mysql_num_rows($result);
if ($num == 1) /* loginName was found */
{
$sql = "SELECT loginName FROM Member
WHERE loginName='$fusername'
AND password=password('$fpassword')";
$num2 = mysql_num_rows($result2);
if ($num2 > 0) /* the password submitted was correct */
{
$auth="yes";
$logname=$fusername;
$today = date("Y-m-d h:m:s");
$sql = "INSERT INTO Login (loginName,loginTime)
VALUES ('$logname','$today')";
mysql_query($sql)
or die("Can't execute query.");
header("Location: login2.php");
}
else
{
unset($do);
$message="You entered an incorrect password, please try again!";
include("login_form.inc");
}
}
elseif ($num == 0)
{
unset($do);
$message = "The login name you entered does not exist, please try again!";
include("login_form.inc");
}
break;
default:
include("login_form.inc");
?>
it includes this page
login_form.inc
<?php
?>
<html>
<form action="Login.php?do=login" method="post">
<table border="0">
<?php
if (isset($message))
echo "<tr><td colspan='2'>$message </td></tr>";
?>
<tr><td align="right"><b>Username</b></td>
<td><input type="text" name ="fusername" size="20" maxsize="20">
</td></tr>
<tr><td width="120" align="right"><b>Password</b></td>
<td><input type="password" name ="fpassword" size="20" maxsize="20">
</td></tr>
<tr><td align="center" colspan="2">
<br><input type="submit" name="log" value="Enter"></td></tr>
</table>
</form>
</td>
</html>
and you dont need to see dbinfo.inc
go to http://www.cubedclub.34sp.com/login.php to see the error
login.php
<?php
session_start();
session_register('auth');
session_register('logname');
include("dbinfo.inc");
switch (@$do)
{
case "login";
$connection = mysql_connect($host, $user, $password)
or die ("Couldn't connect to the server.");
$db = mysql_select_db($database, $connection)
or die ("Couldn't select database");
$sql = "SELECT loginName from Member
WHERE loginName='$fusername'";
$result = mysql_query($sql)
or die ("Couldn't execute query.");
$num = mysql_num_rows($result);
if ($num == 1) /* loginName was found */
{
$sql = "SELECT loginName FROM Member
WHERE loginName='$fusername'
AND password=password('$fpassword')";
$num2 = mysql_num_rows($result2);
if ($num2 > 0) /* the password submitted was correct */
{
$auth="yes";
$logname=$fusername;
$today = date("Y-m-d h:m:s");
$sql = "INSERT INTO Login (loginName,loginTime)
VALUES ('$logname','$today')";
mysql_query($sql)
or die("Can't execute query.");
header("Location: login2.php");
}
else
{
unset($do);
$message="You entered an incorrect password, please try again!";
include("login_form.inc");
}
}
elseif ($num == 0)
{
unset($do);
$message = "The login name you entered does not exist, please try again!";
include("login_form.inc");
}
break;
default:
include("login_form.inc");
?>
it includes this page
login_form.inc
<?php
?>
<html>
<form action="Login.php?do=login" method="post">
<table border="0">
<?php
if (isset($message))
echo "<tr><td colspan='2'>$message </td></tr>";
?>
<tr><td align="right"><b>Username</b></td>
<td><input type="text" name ="fusername" size="20" maxsize="20">
</td></tr>
<tr><td width="120" align="right"><b>Password</b></td>
<td><input type="password" name ="fpassword" size="20" maxsize="20">
</td></tr>
<tr><td align="center" colspan="2">
<br><input type="submit" name="log" value="Enter"></td></tr>
</table>
</form>
</td>
</html>
and you dont need to see dbinfo.inc
go to http://www.cubedclub.34sp.com/login.php to see the error