I can't get this script working, it goes to the PHP page and does nothing. I'm not sure whats wrong though.
Files
Info.inc //A inc file
<?php
//The Database User/Host and password
$host="localhost";
$database="login";
$user="***";
$password="***:;
?>
index.html //Page with the forms
<html><head><title>Home</title></head></html>
<body>
<a href="http://zanjo.freesuperhost.com/login.php">Login to Site</a>
<a href="http://zanjo.freesuperhost.com/login.php?module=new">Register</a>
<form method="post" action="http://www.zanjo.byethost4.com/login.php">
<p>Username </p><input type="text" name="Username"><br>
<p>Password </p><input type="password" name="Password"><br>
<input type="submit" name="submit" value="Login"><br>
</form>
</body></html>
Login.php //Processes the index.html form
<?php session_start();
//Login.php: Login Page
include("info.inc");
switch (@$GET['do'])
{
default:
$connect = mysql_connect($host, $user, $password)
or die("Database connection error."); //Connects to database
$db = mysql_select_db($database, $connect)
or die("Database selection error."); //Selects Database
$sql = "SELECT username FROM members
WHERE username='$POST[Username]'"; //Compares Username provided to the one in the database
$query = mysql_query($sql)
or die ("Couldn't execute MYSQL Query."); //Executes Username comparation
$row = mysql_num_rows($query); //Counts amout of usernames that match
if ($row == 1) //Login Name Was Found
{
$sql = "SELECT username FROM members
WHERE username='$POST[Username]'
AND password=password('$POST[Password]')";
$query2 = mysql_query($sql)
or die("Couldn't execute MYSQL Query number 2.");
$row2 = mysql_num_rows($query2);
if (0 < $row2) //Password matches username and is correct
{
$SESSION['auth']="yes"; //Gives user authentication
$logname=$POST['Username']; //Writes log
$_SESSION['logname'] = $logname;
$today = date("d-m-Y hⓂs");
$sql = "INSERT INTO loginlog (username,logintime)
VALUES ('$logname','$today')";
mysql_query($sql) or die("Couldn't Execute MYSQL Query number 3."); //Inserts log into database
header("Location:members.php");
}
else
{
unset($do)
$message="Username or Password is incorrect.<br>"; //Incorrect Username/Password
include("loginform.php?module=new");
}
}
elseif ($row == 0) //Login name not found
{
unset($do)
$message="The Username you have entered does not exist.<br>";
include("loginform.php?module=new")
}
break;
case "new":
if(empty($POST['Username']))
{
echo "Please fill in your user name."
include "loginform.php?module=new"
exit();
}
if(empty($POST['Password']))
{
echo "Please fill in your Password."
include "loginform.php?module=new"
exit();
}
if(empty($POST['Firstname']))
{
echo "Please fill in your First Name."
include "loginform.php?module=new"
exit();
}
if(empty($POST['Lastname']))
{
echo "Please fill in your Last Name."
include "loginform.php?module=new"
exit();
}
if(empty($POST['Email']))
{
echo "Please fill in your Email addres."
include "loginform.php?module=new"
exit();
}
$POST['Username'] = $Fusername;
$POST['Password'] = $Fpassword;
$POST['Firstname'] = $Ffirstname;
$POST['Lastname'] = $Flastname;
$POST['Email'] = $Femail;
$POST['Confirm'] = $Fconfirm
include("info.inc");
$connect = mysql_connect($host, $user, $password)
or die("Database connection error."); //Connects to database
$db = mysql_select_db($database, $connect)
or die("Database selection error."); //Selects Database
$sql = "SELECT username FROM members
WHERE username='$Fusername'";
$query = mysql_query($sql)
or die("Couldn't execute MYSQL Query.");
$row = mysql_num_rows($query);
if(Fpassword != Fconfirm)
{
unset($GET['do'];
echo "Your two passwords do not match.";
include("loginform.php?module=new");
exit();
}
if (0 < $row)
{
unset($GET['do'];
echo "$Fusername already used. Please select another username.";
include("loginform.php?module=new");
exit();
}
else
{
$today = date("d-m-Y");
$sql = "INSERT INTO members
(username,dateofcreation,pass,email,firstname,lastname)
VALUES
('$Fusername','$today','$Fpassowrd','$Femail','$Ffirstname','$Flastname')";
mysql_query($sql);
$SESSION['auth']="yes";
$_SESSION['log'] = $Fusername;
$emess = "You have sucsessfully signed up at www.zanjo.byethost4.com";
$esubj = "www.zanjo.byethost4.com";
$ehead = "From: www.zanjo.byethost4.com";
mail("$Femail","$esubj","$emess","$ehead");
header("Location: new.php");
}
break;
default:
include("loginform.inc");
}
?>
Loginform.php //Just a substitue inc file, like index.html, but with the switch script, the new case isnt used yet though.
<?php session_start();
switch (@$_GET['module'])
{
default:
echo "<html><head><title>Login</title></head>
<body>
<form method="post">
<input type="text" name="Username">
<input type="password" name="Password">
</form>"
break;
case "new":
echo "<html><head><title>Login</title></head>
<body>
<form method="post">
<p>Username <input type="text" name="Username" maxlength="20"><br>
Password <input type="password" name="Password" maxlength="20"><br>
Confirm Password <input type="password" name="Confirm" maxlength="20"><br>
First Name <input type="text" name ="Firstname" maxlength="20"><br>
Last Name <input type="text" name="Lastname" maxlength="35"><br>
Email Address <input typr="text" name="Email" maxlength="40"><br>
</form>"
break;
default:
}
Thanks