-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexe_registo.php
102 lines (85 loc) · 2.47 KB
/
exe_registo.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
<?php
include("includes/body.php");
if (isset($_POST['registo']))
{
$email=$_POST['mail'];
$local=$_POST['localidade'];
$nome=$_POST['nome'];
$password=$_POST['pass'];
$rua=$_POST['morada'];
$cp=$_POST['cp'];
$morada_val=validateMorada($rua);
$cp_val=validateCP($cp);
$email_val=validateEmail($email);
$password_val=validatePasswords($password, $_POST['conf_password']);
$nome_val=validateName($nome);
if($email_val != "true")
{
header("location:form_registo.php?reg_erro=mail");
exit();
}
elseif($password_val != "true")
{
header("location:form_registo.php?reg_erro=pass");
exit();
}
elseif($nome_val != "true" )
{
header("location:form_registo.php?reg_erro=nome");
exit();
}
elseif($morada_val != "true")
{
header("location:form_registo.php?reg_erro=address");
exit();
}
elseif($cp_val != "true")
{
header("location:form_registo.php?reg_erro=cp");
exit();
}
if ($email_val=='true' && $password_val=='true' && $nome_val=='true' && $morada_val=='true' && $cp_val=='true'){
$val = "";
$possivel = "0123456789abcdefghijklmnopqrstuvwxyz";
$i = 0;
while ($i < 20) {
$char = substr($possivel, mt_rand(0, strlen($possivel)-1), 1);
$val .= $char;
$i++;
}
$sql=mysql_query("insert into clientes(
cliente_nome,
cliente_morada,
cliente_telefone,
cliente_email,
cliente_password,
cliente_nif,
cliente_cp,
cliente_validacao,
cliente_estado,
cliente_localidade)
values(
'$nome',
'$_POST[morada]',
'$_POST[tel]',
'$_POST[mail]',
'$password',
'$_POST[nif]',
'$_POST[cp]',
'$val',
'pendente',
'$local')") or die (mysql_error());
$assunto="Apocalyptic - Activação da sua conta";
$headers .= 'From: Apocalyptic [[email protected]]';
$headers .= 'Reply-To: Apocalyptic [[email protected]]';
$msg = "";
$msg .= "Bem-vindo(a) ".utf8_encode($_POST['nome'])."<br>";
$msg .= " Active a sua conta clicando na seguinte hiperligação: ";
$msg .= "<a href='http://psinf.espr.edu.pt/goncalo/activar_utilizador.php?val=".$val."'>";
mail($email,$assunto,$msg,$headers);
header("location:index.php?registo=done");
}
else
header("location:form_registo.php?registo=not");
}
?>