-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmail.php
More file actions
85 lines (64 loc) · 1.71 KB
/
mail.php
File metadata and controls
85 lines (64 loc) · 1.71 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
75
76
77
78
79
80
81
82
83
84
<?php
include 'header.php';
?>
<?php
$base_dados = "projeto_final";
$host = "127.0.0.1";
$user = "root";
$password = "";
// Create a connection to the database
$conn = new mysqli($host, $user, $password, $base_dados);
// Check the connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Create a table if it doesn't exist
$sql = "CREATE TABLE IF NOT EXISTS contacts (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(100) NOT NULL,
message TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
)";
// Insert data into the table
$name = "John Doe";
$email = "johndoe@example.com";
$message = "Hello, world!";
$sql = "INSERT INTO contacts (name, email, message) VALUES ('$name', '$email', '$message')";
if ($conn->query($sql) === true) {
echo '<div class="mensagem">Informação inserida com sucesso.<br></div>
';
// Simulate sending email
echo '<div class="mensagem">Email enviado com sucesso aguarde o nosso contacto!</div>';
} else {
echo "Error inserting data: " . $conn->error;
}
echo '<button onclick="window.location.href=\'contacts.php\'" class="btn btn-info">Voltar atrás</button>';
// Close the database connection
$conn->close();
echo '
<style>
.mensagem {
width: 400px;
box-shadow: 0px 10px 20px #0000001d;
background-color: #ede5fc;
margin: 20px auto;
margin-bottom: 20px;
text-align: center;
font-family: \'Poppins\', sans-serif;
font-size: large;
padding-bottom: 50px;
}
.btn {
display: block;
margin: 20px auto;
padding: 10px 20px;
font-size: 16px;
text-align: center;
text-decoration: none;
border: none;
border-radius: 4px;
cursor: pointer;
}
</style>';
?>