-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect.php
33 lines (26 loc) · 850 Bytes
/
connect.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
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "coffeeshop";
$conn = new mysqli($servername, $username, $password, $dbname);
if ($conn->connect_error) {
die("Kết nối thất bại: " . $conn->connect_error);
}
$user = $_POST['user'];
$email = $_POST['email'];
$password = $_POST['password'];
$gender = $_POST['gt'];
$hobbies = implode(', ', $_POST['hoppy']);
$nationality = $_POST['quoctich'];
$note = $_POST['note'];
$sql = "INSERT INTO users (username, email, password, gender, hoppy, country, note)
VALUES ('$user', '$email', '$password', '$gender', '$hobbies', '$nationality', '$note')";
if ($conn->query($sql) === TRUE) {
echo "<a href='index.html'></a>";
} else {
echo "Lỗi: " . $sql . "<br>" . $conn->error;
}
// Đóng kết nối đến cơ sở dữ liệu
$conn->close();
?>