Thanks for the reply but there is another problem.
Tried it already
Show an error.
Parse error: parse error, unexpected $end in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\user_conn.php on line 61
The line is 61 is the </html> tag.
here's the code.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Log In</title>
<link href="user_main.css" rel="stylesheet" type="text/css" />
<?php
$username = $_POST['username'];
$password = $_POST['password'];
$password = trim($password);
if (!$username && !$password){
echo 'Enter you username followed by your password';
exit;
}
$mysqli = new mysqli("localhost", "user", "dbpassword", "db");
/* check connection */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
$query = "SELECT username, password FROM users ORDER by username = '$username'
and password = '$password' ";
$result = mysqli_query($mysqli, $query);
if (!$result)
{
echo 'Cannot connect sorry';
exit;
}
else
{
if(mysqli_num_rows($result) == 0){
echo "Username or password is incorrect";
die();
}else {
/* fetch associative array */
while ($row = mysqli_fetch_row($result))
{
printf ( $row[0], $row[1]);
}
/* free result set */
mysqli_free_result($result);
printf ("connection success");
}
$mysqli->close();
?>
</head>
<body>
<center>
</center>
</body>
</html>