-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaccount_insert.php
More file actions
35 lines (28 loc) · 782 Bytes
/
account_insert.php
File metadata and controls
35 lines (28 loc) · 782 Bytes
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
<?php
// Database credentials
$servername = "localhost";
$username = "username";
$password = "password";
$dbname = "database_name";
// Create a connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Prepare a statement
$stmt = $conn->prepare("INSERT INTO users (username, password, email) VALUES (?, ?, ?)");
// Bind parameters
$stmt->bind_param("sss", $username, $password, $email);
// Set parameters
$username = "john_doe";
$password = "password123";
$email = "john_doe@example.com";
// Execute the statement
$stmt->execute();
// Check for errors
if ($stmt->errno) {
echo "Error: " . $stmt->error;
} else {
echo "Data inserted successfully";
}