Reputation: 43677
We have script http://site.com/ourscript.php
How to add something like "enter password" block on that page?
Just some simple, maybe popup.
Like, we open the page in browser, we should type password, if its ok - function will run.
It has to be done only inside requested php file, .htaccess
should not be used.
Thanks.
Upvotes: 0
Views: 106
Reputation: 36637
This is about as simple as it gets:
<html>
<body>
<?php if (isset($_POST['secret']) && $_POST['secret'] == "lolsecurity") { ?>
<h1>Secret Page!</h1>
<p>This type of password-protection is completely open to packet sniffing.</p>
<?php } else { ?>
<form method="POST">
<p>Enter Password:</p>
<input type="password" name="secret">
<input type="submit" value="Submit">
</form>
<?php } ?>
</body>
</html>
Upvotes: 1
Reputation: 94304
Here's a tutorial for a basic authentication system. I'm sure if you spend two minutes googling, you'll find about a million pre-made, ready-to-go PHP login systems.
If you want to create your own, authenticating a user generally requires the following:
Upvotes: 1