Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I tried
- <?php
- session_start();
- echo "<html>
- <head>
- <title>Captcha</title>
- <center>
- <form method='POST' action='captcha.php'>
- <label>Entered Text: </label><input type='text' name='captcha'>
- <input type='submit' name='submit' value='Submit Captcha!'>
- </form>
- </center>
- </head>
- </html>";
- $firstdigit = rand(1, 9);
- $seconddigit = rand(27, 105);
- $lastdigit = rand(1050, 9515);
- $middle = rand(1000, 20000);
- $captcha = "AX-$firstdigit-X-$seconddigit-K3I$middle-AN3Z-$lastdigit";
- $_SESSION['captcha'] = $captcha;
- echo "<b><center><font face=\"Arial\">$captcha</font></center></b>";
- ?>
- and then
- <?php
- $captcha5 = $_SESSION['captcha'];
- $captcha2 = $_POST['captcha']; //This is the input field
- $submit = $_POST['submit']; //This is Submit
- if ($submit) {
- if ($captcha2) {
- echo "Everything is good. $captcha5"; //Echo'd if everything is good
- } else {
- echo "Please fill in all fields."; //Echo'd if $captcha isn't filled out
- }
- } else {
- echo "Direct access not allowed. Please click submit."; //Echo'd if submit is not pressed, and they access this directly.
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement