submit message status

This commit is contained in:
SovereigntyIsNotFreedom 2025-06-11 08:57:58 +01:00
parent 3cb5af0f36
commit 0cf9966611

View file

@ -1,7 +1,7 @@
<?php <?php
session_start(); session_start();
$submission_message = null; // Initialize the variable $submission_message = null; // Initialize the variable
$status_class = null;
if (isset($_POST['submit'])){ if (isset($_POST['submit'])){
// Link checks // Link checks
$link = str_replace(['<','>'],'', $_POST['link']); $link = str_replace(['<','>'],'', $_POST['link']);
@ -14,13 +14,13 @@ if (isset($_POST['submit'])){
$captcha = htmlspecialchars($_POST['captcha']); $captcha = htmlspecialchars($_POST['captcha']);
// Captcha Auth check // Captcha Auth check
if ($captcha != htmlspecialchars($_SESSION['secure'])){ if ($captcha != htmlspecialchars($_SESSION['secure'])){
$submission_message = "<h3 class='submission-status-error'>Captcha Failed</h3>"; $submission_message = "Error: Captcha Failed";
} else { } else {
if (empty($link) or empty($name) or empty($description)){ if (empty($link) or empty($name) or empty($description)){
$submission_message = "<h3 class='submission-status-error'>All of the fields must not be empty</h3>"; $submission_message = "Error: All of the fields must not be empty";
} else { } else {
if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){ if (strlen($link) > 512 or strlen($name) > 64 or strlen($description) > 256 or strlen($sensitive) > 1 or strlen($category) > 64){
$submission_message = "<h3 class='submission-status-error'>Don't exceed the limit</h3>"; $submission_message = "Error: Don't exceed the limit";
} else { } else {
// Open the file once before the loop // Open the file once before the loop
@ -41,7 +41,7 @@ if (isset($_POST['submit'])){
} }
if ($submission_message === null) { // Only set success message if no error occurred if ($submission_message === null) { // Only set success message if no error occurred
$submission_message = "<h3 class='submission-status-success'>Link Successfully Submitted</h3>"; $submission_message = "Link Successfully Submitted";
} }
} }
} }
@ -73,7 +73,7 @@ if (isset($_POST['submit'])){
<html> <html>
<?php include("header.php");?> <?php include("header.php");?>
<div class="width-class"> <div class="width-class">
<?php echo $submission_message; ?> <h3 class="<?php echo str_contains($submission_message, 'Error') ? 'submission-status-error' : 'submission-status-success' ?>"> <?php echo $submission_message ?> </h3>
<center> <center>
<h1>Character Limits</h1> <h1>Character Limits</h1>
<p>Link should be 354</p> <p>Link should be 354</p>
@ -96,7 +96,7 @@ if (isset($_POST['submit'])){
<label style="color:white">Captcha</label> <label style="color:white">Captcha</label>
<div> <div>
<img src="generate.php"> <img src="generate.php">
<input type="text" name="captcha"> <input required type="text" name="captcha">
<input type="submit" value="submit" name="submit" /> <input type="submit" value="submit" name="submit" />
</div> </div>
</form> </form>