Forum Moderators: coopster
These are my details:
txtusername -> for username
txtpassword -> for password
$host = "localhost"
$database = "crismon"
my database type is MYSQL.
I hope someone can help me on this thanks!
If you're happy with simplicity, you can just do:
session_start();
if(!empty($_SESSION['logged_in'])){
echo 'you\'re logged in!';
} elseif(!empty($_POST['username']) &&!empty($_POST['password']) && $_POST['username'] == 'txtusername' && $_POST['password'] == 'txtpassword'){
$_SESSION['logged_in'] = 1;
echo 'thanks for logging in!';
} else {
echo '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
echo 'username: <input type="text" name="username" /><br />
password: <input type="password" type="text" name="password" /><br />
<input type="submit" value="log in" />';
}
session_start();
if(empty($_SESSION['logged_in'])) die('please log in first at <a href="url">this url</a>');
The PHP Session Handling Functions [php.net] page will be of great help as well. You'll also find a few tutorial links in the User Contributed Notes.