• Notice regarding image hosts and attachments. See here.

simple php login?

Suspended
Joined
30 Jan 2005
Posts
467
Hey guys.
If its simple enough, Does anyone know how to code something like this.

Code:
A password box -> if password matches variable already set ($pass = 'password';)
 then include content.php. If password doesn't match include error.php
 
Ahhh, I remember your posts in the Networks section now:)

Try this...

Code:
<?php
$password = "something";

if($_GET['password'] === $password){
    include 'content.php';
} else {
    include 'error.php';
}
?>
Save as secure.php and access the page as secure.php?password=something, or via a form on another page, ie the box like you said:

Code:
<form name="loginform" action="secure.php" method="get">
<input type="password" name="password"  />
<input type="submit" name="submit" value="Login!" />
</form>
That'll go into any HTML file :) (well, XHTML technically)

Could change the get to post to make it more secure, since post requests aren't added to the URL :)
 
Back
Top Bottom