-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinput.php
More file actions
49 lines (37 loc) · 1.17 KB
/
input.php
File metadata and controls
49 lines (37 loc) · 1.17 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
<?php
header("Location: index2.html");
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Connect to the database
$host = "localhost";
$username = "root";
$password = "";
$db_name = "databasepfs";
$conn = mysqli_connect($host, $username, $password, $db_name);
if(!$conn){
echo "Koneksi gagal"; // tampilkan pesan ini
}
// Get form data
$nama = $_POST['nama'];
$alamat = $_POST['alamat'];
$umur = $_POST['umur'];
$email = $_POST['email'];
$password = $_POST['password'];
// Insert data into database
$sql = "INSERT INTO users (nama, alamat, umur, email, password)
VALUES ('$nama', '$alamat', '$umur', '$email', '$password')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo "Terjadi kesalahan, data gagal disimpan.";
}
// Prepare statement
$stmt = $conn->prepare("INSERT INTO users (nama, alamat, umur, email, password) VALUES (?, ?, ?, ?, ?)");
// Bind parameters
$stmt->bind_param("ssisi", $nama, $alamat, $umur, $email, $password);
// Execute statement
$stmt->execute();
// Close connection
mysqli_close($conn);
?>