arghb;10945308 wrote:Does it matter whether I use icexb_dbUsers or dbUsers when referencing them in the php files?
I would have thought so but I don't entirely get what you mean. Is your table called icexb_dbUsers or dbUsers? As long as your connection in the dbConfig.php file is to the correct database then you need to reference the correct table name in that database. You don't need to prefix it with a database name or anything.
Assuming, then, that your login.php matches the code they've given you I'd make the following amendments:
<?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 `dbUsers` "
."WHERE `username`='".$_POST["username"]."' "
."AND `password`=PASSWORD('".$_POST["password"]."') "
."LIMIT 1";
/*** Amendment 1 */
echo "Query: ".$q."<br/>";
/*****/
// Run query
$r = mysql_query($q);
/*** Amendment 2 */
echo "<b>MySQL Result </b><br/>";
print_r($r);
echo "<b>End MySQL Result</b><br/>";
/*****/
if ( $obj = @mysql_fetch_object($r) )
{
/*** Amendment 3 */
echo "Login success <br/>";
/*****/
// Login good, create session variables
$_SESSION["valid_id"] = $obj->id;
$_SESSION["valid_user"] = $_POST["username"];
$_SESSION["valid_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\"><br />";
echo "Password: <input type=\"password\" name=\"password\" size=\"8\"><br />";
echo "<input type=\"submit\" value=\"Login\">";
echo "</form>";
}
?>
You haven't said how it fails so I wasn't sure if you're getting the 'die("Sorry...' bit or it's just not working somehow, hence the 3rd amendment.
If you run that Check the query looks right and then also check the result of the query. That Print_r() method will show everything on one line but if you CTRL+U to view the page source it'll be much easier to read.