-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPhpCaptcha.php
48 lines (40 loc) · 1.29 KB
/
PhpCaptcha.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Simple Captcha Code with PHP</title>
<link rel="stylesheet" href="styles.css" />
<style>
body { margin: 0; padding: 0; font-family: Arial, sans-serif; font-size: 14px; line-height: 180%; }
.center { margin: 0 auto; max-width: 900px; }
</style>
</head>
<body>
<?php
// init variables
$min_number = 1;
$max_number = 15;
// generating random numbers
$random_number1 = mt_rand($min_number, $max_number);
$random_number2 = mt_rand($min_number, $max_number);
?>
<div class="center">
<h1>Simple PHP Captcha Code for HTML Forms</h1>
<p> </p>
<form action="validateCaptcha.php" method="POST">
<p>
Resolve the simple captcha below: <br />
<?php
echo $random_number1 . ' + ' . $random_number2 . ' = ';
?>
<input name="captchaResult" type="text" size="2" />
<input name="firstNumber" type="hidden" value="<?php echo $random_number1; ?>" />
<input name="secondNumber" type="hidden" value="<?php echo $random_number2; ?>" />
</p>
<p>
<input type="submit" value="submit" />
</p>
</form>
</div>
</body>
</html>