I’m trying to create a login.php page for my website. Everytime I log in it goes to my “Sorry, could not log you in. Wrong login information.” error. I have seen this code on a few website and now have copied it exactly and it still isnt working. Im just learning PHP… And just dont know what to do… Can anyone take a look and give me a little insight into what is going on…
[php]<?php
session_start();
// dBase file
include “dbconfig.php”;
if ($_GET[“op”] == “login”)
{
if (!$_POST[“username”] || !$_POST[“password”])
{
die(“You need to provide a username and password.”);
}
// Create query
$q = "SELECT * FROM `contacts` "
."WHERE `username`='".$_POST["username"]."' "
."AND `password`=PASSWORD('".$_POST["password"]."') "
//."AND `password`='".$_POST["password"]."' "
."LIMIT 1";
// Run query
$r = mysql_query($q) or die('Query failed: ' . mysql_error());
if ($obj = mysql_fetch_object($r))
{
// Login good, create session variables
$_SESSION["valid_id"] = $obj->id;
$_SESSION["username"] = $_POST["username"];
$_SESSION["time"] = time();
// Redirect to member page
Header("Location: members.php");
}
else
{
// Login not successful
die("Sorry, could not log you in. Wrong login information.");
}
}
else
{
//If all went right the Web form appears and users can log in
echo “<form action=”?op=login" method=“POST”>";
echo “Username: <input name=“username” size=“15”>
”;
echo “Password: <input type=“password” name=“password” size=“8”>
”;
echo “<input type=“submit” value=“Login”>”;
echo “”;
}
?>[/php]
Any help will be greatly apprieciated!!! Thanks!!