· 6 years ago · Nov 12, 2019, 09:24 PM
1<!DOCTYPE html>
2
3<html>
4
5<head>
6 <meta charset="utf-8">
7 <title>Register | InforResolve.com</title>
8 <link rel="stylesheet" href="css/stylelogin.css" />
9</head>
10
11<body>
12
13 <form class="login" action="registardb.php" method="post">
14 <h1 class="login-title">Registrar</h1>
15 <img src="img/logo.png" class="logo" alt="">
16 <input type="text" class="login-input" name="user" placeholder="Nome" required />
17 <input type="text" class="login-input" name="email" placeholder="Email" required>
18 <input type="password" class="login-input" name="password" placeholder="Password" id="password" required>
19 <input type="password" class="login-input" name="confirm_password" id="confirm_password" placeholder="Confirmar Password" required>
20 <input type="submit" name="submit" value="Registar" class="login-button">
21 <p class="login-lost">Já tens conta? <a href="login.php">Login</a></p>
22 <p class="login-lost"><a href="index.php">Página Inicial</a></p>
23 </form>
24
25
26
27 <script>
28 var password = document.getElementById("password"),
29 confirm_password = document.getElementById("confirm_password");
30
31 function validatePassword() {
32 if (password.value != confirm_password.value) {
33 confirm_password.setCustomValidity("Password incorreta.");
34 } else {
35 confirm_password.setCustomValidity('');
36 }
37 }
38
39 password.onchange = validatePassword;
40 confirm_password.onkeyup = validatePassword;
41 </script>
42
43
44</body>
45
46</html>
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66<?php
67require('ligardb.php');
68
69$stmt = $DB->prepare("INSERT INTO clientes(user, email, password) VALUES (?, ?, SHA1(?))");
70$stmt->bind_param('sss', $_POST["user"], $_POST["email"], $_POST["password"]);
71$stmt->execute();
72header ('location: index.php');
73?>
74
75
76
77
78
79DROP TABLE IF EXISTS `clientes`;
80CREATE TABLE IF NOT EXISTS `clientes` (
81 `id` int(5) NOT NULL AUTO_INCREMENT,
82 `user` varchar(30) NOT NULL,
83 `email` varchar(50) NOT NULL,
84 `password` varchar(50) NOT NULL,
85 PRIMARY KEY (`id`)
86) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=latin1;