<?php
session_start();
$name = array();
$pass = array();
<?php
session_start();
// dBase file
require_once 'news/db.php';
require_once 'news/config.php';
require_once 'news/functions.php';
if ($_GET["op"] == "login")
{
if (!$_POST["username"] || !$_POST["password"])
{
die("You need to provide a username and password.");
}
// Create query
$pas = md5(SALT . $_POST['password']);
$q = "SELECT * FROM `news30_users` "
."WHERE `user`='".$_POST["username"]."' "
."AND `newpass`= '$pas' "
."LIMIT 1";
// Run query
$r = mysql_query($q);
if ( $obj = @mysql_fetch_object($r) )
{
// Login good, create session variables
$_SESSION["valid_id"] = $obj->uid;
$_SESSION["valid_age"] = $obj->profile_age;
$_SESSION["valid_user"] = $_POST["username"];
$_SESSION["valid_time"] = time();
// Redirect to member page
Header("Location: mods.php");
}
else
{
// Login not successful
die("Sorry, could not log you in. Wrong login information. $pas");
}
}
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>";
}
?>
<?php
session_start();
if (!$_SESSION["valid_user"])
{
// User not logged in, redirect to login page
Header("Location: login.php");
}
// Member only content
// ...
// ...
// ...
// Display Member information
echo "<p>User ID: " . $_SESSION["valid_id"];
echo "<p>Username: " . $_SESSION["valid_user"];
echo "<p>Age: " . $_SESSION["valid_age"];
echo "<p>Logged in: " . date("m/d/Y", $_SESSION["valid_time"]);
// Display logout link
echo "<p><a href=\"logout.php\">Click here to logout!</a></p>";
?>
<?php
session_start();
session_unset();
session_destroy();
// Logged out, return home.
Header("Location: index.php");
?>
Is it posible, to make this login, with mysql database connection ? From news30_users.
sandjuks112,