i am a php newbie
i have a simple table using MySQL called members which stores memberid and password. i have created a simple html form with username and password fields and got the following php script to check whether the user exists.
Code: Select all
<?php
session_start();
mysql_connect("localhost", "??", "??") or die(mysql_error());
echo "Connected to MySQL<br />";
mysql_select_db("name") or die(mysql_error());
echo "Connected to Database";
if(isset($_POST['submit'])) {
if(mysql_num_rows(mysql_query("SELECT memberid, password FROM members WHERE memberid = '".$_POST['username']."' && password = '".$_POST['password']."' ")) > 0) {
if(mysql_num_rows(mysql_query("SELECT id FROM members WHERE memberid = '".$_POST['username']."' && password = '".$_POST['password']."' ")) > 0 ) {
$_SESSION['logged'] = true;
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
echo "<font color='green'>You have succsfully logged in!</font>";
}else{ //if the username and password aren't from the same account but does exist
echo "<font color='red'>Incorrect login! Please try again</font>";
}
}else{ //username/password doesn't exist
echo "<font color='red'>Username/Password doesn't exist!</font>";
}
}
?>question is how do i direct the successful login to their own page. i.e their account page? instead of just displaying a message saying successfull login. and once the user has logged in to their account what kind of function will i need so that the persons account page is only unique to them?
any help would be greatly appreciated. many thanks