Jump to content

Need to password protect one page.... Where to start?


james13009

Recommended Posts

Im doing a website for a friend and i need to password protect one page of it. It doesn't need any fancy login, and there will be only ever one user name and password. (which may need changing but not very often). Where can i find the a simple basic script like this. Not sure where to start.

 

Many thanks

<?php
$username = "theking";
$password = "cheese";
if (isset($_POST['username']) &&($_POST['username'] == $username && $_POST['password'] == $password)){
	//put your sensitive stuff here
}
else{
?>
<center><form method="POST" action="?">
	<table border="0">
		<tr>
			<td>Username:</td>
			<td><input type="text" name="username"></td>
		</tr>
		<tr>
			<td>Password:</td>
			<td><input type="password" name="password"></td>
		</tr>
		<tr>
			<td> </td>
			<td><input type="submit" name="submit" value="Login"></td>
		</tr>
	</table>
	</form>
</center>
<?php
}

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.