Hi There,
I've got a membership script and a login using PHP and MySQL databases however when it logs in it simply displays a PHP page - the same one for all users.
I want to be able to customise the members page so it says things like:
Hello, <username>.
I also want users to be able to update their account details so they update on MySQL.
How do I do that?
Here is my login.php script:
<?php
include("functions.php"); // Includes the db and form info.
session_start(); // Starts the session.
if ($_SESSION['logged'] == 1) { // User is already logged in.
header("Location: main.php"); // Goes to main page.
exit(); // Stops the rest of the script.
} else {
if (!isset($_POST['submit'])) { // The form has not been submitted.
include 'loginform.php';
} else {
$username = form($_POST['username']);
$password = md5($_POST['password']); // Encrypts the password.
$q = mysql_query("SELECT * FROM `users` WHERE username = '$username' AND password = '$password'") or die (mysql_error()); // mySQL query
$r = mysql_num_rows($q); // Checks to see if anything is in the db.
if ($r == 1) { // There is something in the db. The username/password match up.
$_SESSION['logged'] = 1; // Sets the session.
header("Location: main.php"); // Goes to main page.
exit(); // Stops the rest of the script.
} else { // Invalid username/password.
exit("Incorrect username/password!"); // Stops the script with an error message.
}
}
}
mysql_close($db_connect); // Closes the connection.
?>
Here is my main.php script:
<?php
include("functions.php"); // Includes the db and form info.
session_start(); // Starts the session.
if ($_SESSION['logged'] != 1) { // There was no session found!
header("Location: login.php"); // Goes to login page.
exit(); // Stops the rest of the script.
}
include 'updateinfo.php';
?>