-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathphp.php
More file actions
36 lines (29 loc) · 960 Bytes
/
php.php
File metadata and controls
36 lines (29 loc) · 960 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
36
<?php
// Database connection settings
$servername = "your_servername";
$username = "your_username";
$password = "your_password";
$dbname = "password_manager";
// Create a database connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$website = $_POST["website"];
$username = $_POST["username"];
$password = $_POST["password"];
// Prepare and execute the SQL query to insert data
$sql = "INSERT INTO passwords (website, username, password) VALUES (?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("sss", $website, $username, $password);
if ($stmt->execute()) {
echo "Password saved successfully!";
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
}
$conn->close();
?>