Created
February 12, 2024 15:22
-
-
Save marstamyan/b4da917393eecc770eeb49f65b615f69 to your computer and use it in GitHub Desktop.
This file checks user-entered access codes for validity, granting access if the code is correct, and prompting for re-entry if incorrect.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Check if a valid access code has been submitted | |
if (isset($_POST['access_code'])) { | |
$stored_hash = 'a891af9b4934fe765b5778469d1f1f45'; // Replace with your actual MD5 hash | |
$entered_code = $_POST['access_code']; | |
$entered_hash = md5($entered_code); // Hash the entered code | |
if ($entered_hash === $stored_hash) { | |
// Display your link | |
echo '<a href="https://www.google.com/" target="_blank">Requested link</a>'; | |
// You can also store access information in session or cookies | |
} else { | |
// Display error message | |
echo 'Incorrect access code. Please try again.'; | |
// Display the code input form again | |
display_code_form(); | |
} | |
} else { | |
// Display the code input form | |
display_code_form(); | |
} | |
// Function to display the code input form | |
function display_code_form() { | |
?> | |
<form method="post" action=""> | |
<label for="access_code">Enter access code:</label> | |
<input type="text" name="access_code" id="access_code"> | |
<input type="submit" value="Submit"> | |
</form> | |
<?php | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment