-
Notifications
You must be signed in to change notification settings - Fork 1
/
userEditCons.php
58 lines (46 loc) · 2.62 KB
/
userEditCons.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
<?php
include('session.php');
require 'php/PHPMailerAutoload.php';
include 'php/functions.php';
$idcookie = $_COOKIE["idcons"];
$mailnome = $_POST["nome"];
$mailmail = $_POST["userEmail"];
$mail = new PHPMailer;
//$mail->SMTPDebug = 3; // Enable verbose debug output
$mail->isSMTP(); // Set mailer to use SMTP
$mail->Host = 'smtp.gmail.com;smtp-relay.gmail.com'; // Specify main and backup SMTP servers
$mail->SMTPAuth = true; // Enable SMTP authentication
$mail->Username = '[email protected]'; // SMTP username
$mail->Password = 'arkham2016'; // SMTP password
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
$mail->Port = 587; // TCP port to connect to
$mail->CharSet = 'UTF-8';
$mail->setFrom('[email protected]', 'Condominus SA');
$mail->addAddress($mailmail, $mailnome); // Add a recipient
//$mail->addAddress('[email protected]', 'Pedro Palha'); // Name is optional
$mail->addReplyTo('[email protected]', 'Information');
//$mail->addCC('[email protected]');
//$mail->addBCC('[email protected]');
//$mail->addAttachment('/var/tmp/file.tar.gz'); // Add attachments
//$mail->addAttachment('/tmp/image.jpg', 'new.jpg'); // Optional name
$mail->isHTML(true); // Set email format to HTML
$mail->Subject = 'Informações Alteradas';
$mail->Body = 'Foram alteradas as suas informações, caso não tenha pedido essa informação informe-nos';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';
$query= "UPDATE users
SET user_nicename='" . $_POST["nome"] . "', user_mail='" . $_POST["userEmail"] . "', user_adress='" . $_POST["morada"] . "', user_phone='" . $_POST["phone"] . "' WHERE id_user='" . $idcookie . "'";
if ((mysqli_query($connection, $query)) && ($mail->send())) {
echo "<script type=\"text/javascript\">".
"alert('Atualização feita com sucesso');"
. "window.location = 'menu.php';".
"</script>";
}
else {
echo "<script type=\"text/javascript\">".
"alert('Erro');".
"window.location = 'menu.php';".
"</script>";
echo "Error: " . $query . "<br>" . mysqli_error($connection);
}
$connection->close();
?>