📁 Folder Navigator
Position:
Root
/
faith
/
vpnp1
/
admin
/
branding
/
brandname
Create
Folders
📁 infoticker
Rename
Copy
Delete
📁 uploads
Rename
Copy
Delete
Files
📄 data.csv
📄 data.txt
📄 error_log
📄 form.php
📄 index.php
📄 read.txt
📄 read2.txt
📄 submissions.txt
📝 File Editor
Editing:
form.php
<!DOCTYPE html> <html> <head> <title>Brand Introduction and Contact Info</title> <style> table { border-collapse: collapse; width: 80%; margin-top: 20px; } th, td { border: 1px solid #ddd; padding: 8px; text-align: left; } th { background-color: #f2f2f2; } .success { color: green; } .error { color: red; } </style> </head> <body> <h2>Submit Brand Information</h2> <?php $upload_success_message = ""; $upload_error_message = ""; $target_dir = "uploads/"; // 1. Handle Form Submission and File Storage if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["submit_form"])) { $brand_name = htmlspecialchars($_POST["brand_name"]); $contact_email = htmlspecialchars($_POST["contact_email"]); $introduction = htmlspecialchars($_POST["introduction"]); $target_file = $target_dir . basename($_FILES["brand_logo"]["name"]); $uploadOk = 1; $fileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION)); // Check if file was uploaded without errors if (isset($_FILES["brand_logo"]) && $_FILES["brand_logo"]["error"] == 0) { // Check if directory exists, create if not if (!is_dir($target_dir)) { mkdir($target_dir, 0755, true); } // Check if file already exists if (file_exists($target_file)) { $upload_error_message = "Sorry, file already exists."; $uploadOk = 0; } // Allow certain file formats (optional) if($fileType != "jpg" && $fileType != "png" && $fileType != "jpeg" && $fileType != "gif" ) { $upload_error_message = "Sorry, only JPG, JPEG, PNG & GIF files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { $upload_error_message = "Sorry, your file was not uploaded. " . $upload_error_message; } else { if (move_uploaded_file($_FILES["brand_logo"]["tmp_name"], $target_file)) { $upload_success_message = "The file ". htmlspecialchars(basename($_FILES["brand_logo"]["name"])). " has been uploaded."; // Store form data to a file (e.g., a CSV file) $data_file = 'data.csv'; $file_data = [$brand_name, $contact_email, $introduction, $target_file]; $fp = fopen($data_file, 'a'); fputcsv($fp, $file_data); fclose($fp); } else { $upload_error_message = "Sorry, there was an error uploading your file."; } } } else { $upload_error_message = "No file selected or an upload error occurred."; } } ?> <?php if ($upload_success_message): ?> <p class="success"><?php echo $upload_success_message; ?></p> <?php endif; ?> <?php if ($upload_error_message): ?> <p class="error"><?php echo $upload_error_message; ?></p> <?php endif; ?> <!-- HTML Form --> <form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" enctype="multipart/form-data"> <label for="brand_name">Brand Name:</label><br> <input type="text" id="brand_name" name="brand_name" required><br><br> <label for="contact_email">Contact Email:</label><br> <input type="email" id="contact_email" name="contact_email" required><br><br> <label for="introduction">Introduction:</label><br> <textarea id="introduction" name="introduction" rows="4" required></textarea><br><br> <label for="brand_logo">Brand Logo (Image):</label><br> <input type="file" id="brand_logo" name="brand_logo" required><br><br> <input type="submit" value="Submit" name="submit_form"> </form> <h2>Submitted Brand Information</h2> <!-- 2. Display File Contents in a Table --> <?php $data_file = 'data.csv'; if (file_exists($data_file)): $file = fopen($data_file, 'r'); ?> <table> <thead> <tr> <th>Brand Name</th> <th>Contact Email</th> <th>Introduction</th> <th>Logo File Path</th> </tr> </thead> <tbody> <?php while (($line = fgetcsv($file)) !== FALSE): ?> <tr> <?php foreach ($line as $cell): ?> <td><?php echo htmlspecialchars($cell); ?></td> <?php endforeach; ?> </tr> <?php endwhile; ?> </tbody> </table> <?php fclose($file); else: ?> <p>No brand information submitted yet.</p> <?php endif; ?> </body> </html>
💾 Save Changes