Hi everyone,
Having a little difficulty getting anything from this.
The code appears to me to be correct, then again I have been looking at it for hours, so it is possible there could be a mistake...... :/
Anyway, the code seems sound, should let me login and instead gets nothing from the database and says login failed every single time.
Any help much appreciated!
<?php
session_start();
require("./config.php");
$con = mysql_connect($sqlserver,$sqluser,$sqlpassword);
if (!$con)
{
die('Connection to SQL Server failed. Error: ' . mysql_error());
}
$username = $_POST['username'];
$password = $_POST['password'];
mysql_select_db($sqldb, $con);
$sql= "SELECT * FROM admins WHERE username='$username' AND password='$password'";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error() . "<br />");
$count = mysql_num_rows($result);
if($count==1)
{
$_SESSION["username"] = $username;
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0;URL=./successpage.php\">\n";
}
else
{
echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"1;URL=./index.php?msg=Sorry those details were unrecognised, please try again.\">\n";
}
mysql_close($con);
?>
Cheers,
Jack.