login help
Posted: Fri Apr 22, 2005 4:46 pm
i was wondering if someone could help me with my login script that i made i was wondering if someone could show me how to make it where the admin can login on the same login place as players but go to admin page.. and help me make the script so people can recover there passwords using there email address they signed up with the username... here is the login scrip
Thank you
Smackie
Code: Select all
<?php
session_start();
// dBase file
include "dbConfig.php";
if ($_GET["op"] == "login")
{
if (!$_POST["username"] || !$_POST["password"])
{
die("Please go back and Supply a username and password.");
}
// Create query
$q = "SELECT * FROM `dbUsers` "
."WHERE `username`='".$_POST["username"]."' "
."AND `password`=PASSWORD('".$_POST["password"]."') "
."LIMIT 1";
// Run query
$r = mysql_query($q);
if ( $obj = @mysql_fetch_object($r) )
{
// Login O.K., 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
{
include "colors.html";
echo "<form action=\"?op=login\" method=\"POST\">";
echo "Username: <input name=\"username\" size=\"15\"><br />";
echo "Password: <input type=\"password\" name=\"password\" size=\"15\"><br />";
echo "<input type=\"submit\" value=\"Login\">";
echo "</form>";
}
?>Smackie