-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
145 lines (99 loc) · 3.86 KB
/
index.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
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<!DOCTYPE HTML>
<html lang="pt-br">
<head>
<meta charset="UTF-8">
<title>Twitter clone</title>
<!-- css externo -->
<link rel="stylesheet" type= "text/css" href="index.css"/>
<!-- font-family shippori -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@200;300&family=Roboto&family=Shippori+Antique&family=Shippori+Antique+B1&display=swap" rel="stylesheet">
<!-- javascript -->
<script type="text/javascript" >
/*const fields = document.querySelectorAll("[required]");
function customValidation(event) {
const field = event.target
oninvalid="setCustomValidity(' ')";
}
for (field of fields){
field.addEventListener("invalid", customValidation);
}*/
/*let email = document.getElementById('campo_email');
let senha = document.getElementById('campo_senha');
email.form.onsubmit = function(){
email.setCustomValidity(' ');
}
senha.form.onsubmit = function(){
email.setCustomValidity(' ');
}*/
function validaçao(){
campo_vazio = false;
let email = document.getElementById('campo_email').value;
let senha = document.getElementById('campo_senha').value;
if(email == "" ){
// altera a cor do input quando vazio
let el = document.getElementById('campo_email');
el.style.cssText = 'border: 2px solid #F26E1D;';
document.getElementById('erro_email').innerHTML = '<p>Preencha o email</p>';
campo_vazio = true;
}
if(senha == "" ){
// altera a cor do input quando vazio
let el = document.getElementById('campo_senha');
el.style.cssText = 'border: 2px solid #F26E1D;';
document.getElementById('erro_senha').innerHTML = '<p>Preencha a senha</p>';
campo_vazio = true;
}
if(campo_vazio) return false;
}
</script>
</head>
<body>
<?php
//capta a variável erro passada pelo htttps do browser
//se a variável for iniciada passa o valor 1 a variável, caso não, passa o valor 0
$erro = isset($_GET['erro'])? $_GET['erro'] : 0;
?>
<div class="container">
<div class="logo">
<picture>
<source media="(max-width:650px)" srcset="imagens/twitter_icon_bigger.png">
<source media="(max-width:465px)" srcset="imagens/twitter_icon_bigger.png">
<img src="imagens/twitter_icon_bigger.png" style="width:500px;">
</picture>
</div>
<div class="conteudo">
<h1 class="title">Bem vindo ao twitter clone</h1>
<p class="subtitle">Veja o que está acontecendo agora...</p>
<form method="post" action="valida_usuario.php" id="formLogin">
<div class="links_forms">
<label for="campo_email"
style = 'text-decoration: none;
font-size: 1.3rem;
font-weight: 600;
padding-right: 3%'>
<p>Login</p>
</label>
<a href="inscreva-se.php">Inscrever-se</a>
</div>
<div class="form-group">
<input type="email" required class="form-control" id="campo_email" name="email" placeholder="Email"/> <!-- retira a mensagem default do required -->
<span id="erro_email"></span>
</div>
<div class="form-group">
<input type="password" required class="form-control red" id="campo_senha" name="senha" placeholder="Senha"/> <!-- retira a mensagem default do required -->
<span id="erro_senha"></span>
</div>
<button type="buttom" class="form-bottom" id="btn_login" onclick="validaçao()">Entrar</button>
<br /><br />
<?php
if($erro == 1){
echo "<p class='comunicado_erro'>Usuário e ou senha inválido(s)</p>";
}
?>
</form>
</div><!--conteudo-->
</div><!--container-->
</body>
</html>