'],'', $_POST['link']); // Clear user input $link = htmlspecialchars($link); $name = htmlspecialchars($_POST['name']); $description = htmlspecialchars($_POST['description']); $sensitive = htmlspecialchars($_POST['sensitive']); $category = htmlspecialchars($_POST['category']); $captcha = htmlspecialchars($_POST['captcha']); // Captcha Auth check if ($captcha != htmlspecialchars($_SESSION['secure'])){ $submission_message = "Error: Captcha Failed"; } else { if (empty($link) or empty($name) or empty($description)){ $submission_message = "Error: All of the fields must not be empty"; } else { if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){ $submission_message = "Error: Don't exceed the limit"; } else { // Open the file once before the loop $file = fopen("../submissions/submission.csv", "a"); if ($file !== false) { // Create an array with the inputs to write as a single row $row = [$link, $name,$description,$category,$sensitive]; // Write the row to the CSV file fputcsv($file, $row, ',', '"'); // Close the file after writing fclose($file); } else { // Handle error opening the file error_log("Error opening the file."); } if ($submission_message === null) { // Only set success message if no error occurred $submission_message = "Link Successfully Submitted"; } } } } } ?>
Link should be 354
Name should be 64
Description should be 256
Category should be 64
Sensitive should be 1