-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.php
More file actions
74 lines (66 loc) · 1.66 KB
/
index.php
File metadata and controls
74 lines (66 loc) · 1.66 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<?php
session_start();
//SE NÃO EXISTIRA SESSÃO captcha
if(!isset($_SESSION['captcha'])) {
//CRIANDO UM NÚMERO ALEATORIO
$n = rand(1000, 9999);
$_SESSION['captcha'] = $n;
}
//SE O O CAMPO CODIGO ESTIVER PREENCHIDO
if(!empty($_POST['codigo'])) {
$codigo = $_POST['codigo'];
//SE O CODIGO DIGITADO BATER COM O CAPTCHA EXIBIDO
if($codigo == $_SESSION['captcha']) {
$alert = '<div class="alert alert-success">Captcha Correto!</div>';
}
//CASO CONTRARIO
else {
$alert = '<div class="alert alert-danger">Captcha Incorreto!</div>';
//GERANDO NOVO CAPTCHA
$n = rand(1000, 9999);
$_SESSION['captcha'] = $n;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Captcha</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.js"></script>
<script type="text/javascript" src="js/script.js"></script>
<style type="text/css">
#cap{
height: 60px;
font-size: 30px;
text-align: center;
text-decoration: line-through;
}
</style>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-sm-4">
</div>
<div class="col-sm-4 text-center">
<?php
if (isset($alert)) {
echo $alert;
}
?>
<h3>Script de Captcha</h3><br>
<form method="POST">
<img src="imagem.php" width="200" height="100">
<br><br>
<input type="text" name="codigo" class="form-control" autofocus=""><br>
<input type="submit" value="Entrar" />
</form>
</div>
<div class="col-sm-4">
</div>
</div>
</div>
</body>
</html>