This repository was archived by the owner on Sep 5, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathprocess.php
More file actions
60 lines (55 loc) · 1.82 KB
/
process.php
File metadata and controls
60 lines (55 loc) · 1.82 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
50
51
52
53
54
55
56
57
58
59
60
<?php
// Check if the form has been submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Get the form data
$login_id = $_POST["Login ID"];
$password = $_POST["Password"];
$email = $_POST["Email"];
$phone = $_POST["Phone"];
$username = $_POST["Username"];
$name = $_POST["Name"];
$content_guidelines = $_POST["ContentGuidelines"];
$birthday = $_POST["Birthday"];
$tos_agreement = $_POST["ToS Agreement"POST]
// Hash the password using password_hash()
$hashed_password = password_hash($password, PASSWORD_DEFAULT);
// Read the CSV file
$fp = fopen("profiles.csv", "r");
$csvData = array();
while (($row = fgetcsv($fp, 1000, ","))!== FALSE) {
$csvData[] = $row;
}
fclose($fp);
// Check for duplicate email, phone, or username
$duplicateFound = false;
foreach ($csvData as $row) {
if ($row[4] == $email || $row[5] == $phone || $row[6] == $username) {
$duplicateFound = true;
break;
}
}
if ($duplicateFound) {
// Display an error message
echo "Error: Email, phone, or username is in use.";
} else {
// Generate a new account ID
do {
$accountId = rand(100000000000000000, 999999999999999999); // 17-18 digits
$duplicateAccountIdFound = false;
foreach ($csvData as $row) {
if ($row[1] == $accountId) {
$duplicateAccountIdFound = true;
break;
}
}
} while ($duplicateAccountIdFound);
// Write the new user data to the CSV file
$fp = fopen("profiles.csv", "a");
fputcsv($fp, array("", $accountId, $login_id, $hashed_password, $email, $phone, $username, $name, "", "", "", "", "", "", $content_guidelines, "", "", "", "", "", "", "", "", "", "", "", "", "", ""));
fclose($fp);
// Redirect to a success page or display a success message
header("Location: home/index.html");
exit;
}
}
?>