Ok, so l am new to php ... sort of, now l have managed to throw this together:
<?php
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("test_database", $con);
if(isset($_POST['Login']))
{
if($_POST['username']!='' && $_POST['password']!='')
{
//Use the input username and password and check against 'users' table
$query = mysql_query('SELECT ID, username, Active FROM persons WHERE username = "'.mysql_real_escape_string($_POST['username']).'" AND password = "'.mysql_real_escape_string(md5($_POST['password'])).'"');
if(mysql_num_rows($query) == 1)
{
$row = mysql_fetch_assoc($query);
if($row['Active'] == 1)
{
$_SESSION['user_id'] = $row['ID'];
$_SESSION['logged_in'] = TRUE;
header("Location: members.php");
}
else {
$error = 'Your membership was not activated. Please open the email that we sent and click on the activation link';
}
}
else {
$error = 'Login failed !';
}
}
else {
$error = 'Please enter both your username and password to access your account';
}
}
?>
Here is my html:
<form action="login.php" method="get">
Username: <input type="text" name="username" /> <br>
Password: <input type="password" name="password" /> <br><br>
<input type="submit" value="Login" />
<input type="reset" value="Reset" /> <br>
</form>
Now, this is not working, when l try it it displays a blank white page, anyone know what l have done wrong?