-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsignup_process.php
49 lines (40 loc) · 1.42 KB
/
signup_process.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
header("Access-Control-Allow-Origin: https://violetz12.github.io");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type, Authorization");
if ($_SERVER['REQUEST_METHOD'] === 'OPTIONS') {
header("HTTP/1.1 204 No Content");
exit();
}
if (isset($_POST['username']) && isset($_POST['password'])) {
$username = $_POST['username'];
$password = $_POST['password'];
// Database credentials
$servername = "sql309.infinityfree.com";
$dbUsername = "if0_37992676";
$dbPassword = "uQrplqHgcTpR56";
$dbName = "if0_37992676_user_db";
// Create connection
$conn = new mysqli($servername, $dbUsername, $dbPassword, $dbName);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
// Hash the password for security
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Insert user into database
$stmt = $conn->prepare("INSERT INTO users (username, password) VALUES (?, ?)");
$stmt->bind_param("ss", $username, $hashed_password);
if ($stmt->execute()) {
echo "Sign up successful!";
header("Location: https://violetz12.github.io/Partner-Portfolio");
} else {
echo "Error: " . $stmt->error;
}
$stmt->close();
$conn->close();
} else {
header("Location: https://violetz12.github.io/Partner-Portfolio");
exit();
}
?>