Quote:
Originally Posted by alexgeek
Since there's only a few person viewing it, you'd only need one or two usernames so mysql would be pointless i guess.
This might work, haven't tested it.
login form:
- Code: Select all
<form action="login.php" method="post">
<p>Username<br>
<input type="text" name="user"></p>
<p>Password:<br>
<input type="password" name="pass"></p>
<p><input type="submit" value="login"></p>
</form>
login. php:
- PHP: Select all
<?php session_start $username=$_POST['user']; $password=$_POST['pass']; $checkuser="username"; //replace username with your own. $checkpass="password123"; //replace with your own password like above
if($username == $checkuser && $password == $checkpass) { $_SESSION['loggedin'] == $username; } else { echo "wrong username/password"; } ?>
everypage that should be protected from people not logged in should have:
- PHP: Select all
<?php session_start; if (!isset($_SESSION['loggedin'])) { echo "you aren't logged in"; exit(); } ?>
<!-- html here -->
That should work 
Sorry if you know how to do this already.
|
Says there is an error on this line
- PHP: Select all
$username=$_POST['user'];