|
OK, I have been trying for a few days now to get this working and I am still unable to. I can get the login form to submit to the processing program written in php but then the web browser just sits there not doing a thing. Here's the processing code see if you can help:
<?php
session_start();
session_register('auth');
session_register('tries');
include ('include/1040.inc');
$auth = 'no'; //automatically assumes user is not allowed in the site
if ($tries >= 3)
{
header ("Location: fail.php");
die();
}
$connection = mysql_connect($host,$user,$ps) //connects to the MySQL server
or die ("Could not connect to the server.");
$db = mysql_select_db($dbname,$connection) //connects to the MySQL database
or die ("Could not connect to database.");
$sql = "SELECT use_username FROM userinfo WHERE use_username='$user'";
$result = mysql_query($sql)
or die("Couldn't execute query 1");
$num = mysql_num_rows($result);
if ($num == 1)//login name was found
{
$sql = "SELECT use_username FROM userinfo WHERE use_username='$user' AND use_password='$password'";
$result2 = mysql_query($sql)
or die("Couldn't execute query 2");
$num2 = mysql_num_rows($result2);
if ($num2 > 0)
{
$auth = "yes";
$tries = $tries + 1;
if ($page != '')
{
mysql_close($connection);
header ("Location: index.php");//change after login works
die();
} //loads the users requested page
else
{
mysql_close($connection);
header ("Location: index.php");
echo "$tries";
die();
}//if no page is requested index is loaded
}
else //username or password is not correct
{
mysql_close($connection);
$tries = $tries + 1;
header ("Location: form.php");//sends user to the login form
die("Your username or password is wrong, please try again.");
//lets the user try again
}
}
|