Vehicle Listing Form

// Configuration
$storage_file = 'vehicles.txt';
$separator = ':::';
$message = '';

// Check if the form was submitted
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// Sanitize and collect input data
$data = [
'year' => htmlspecialchars($_POST['year']),
'make' => htmlspecialchars($_POST['make']),
'model' => htmlspecialchars($_POST['model']),
'mileage' => htmlspecialchars($_POST['mileage']),
'description' => str_replace(["\r", "\n"], " ", $_POST['description']), // Remove newlines
'issues' => str_replace(["\r", "\n"], " ", $_POST['issues']),
'price' => htmlspecialchars($_POST['price']),
'location' => htmlspecialchars($_POST['location']),
'contact_phone' => htmlspecialchars($_POST['contact_phone']),
'contact_email' => htmlspecialchars($_POST['contact_email']),
'timestamp' => date('Y-m-d H:i:s')
];

// Create the string line
$line = implode($separator, $data) . PHP_EOL;

// Append to the flat file
if (file_put_contents($storage_file, $line, FILE_APPEND | LOCK_EX)) {
$message = "

Vehicle listing saved successfully!

";
} else {
$message = "

Error: Could not save data.

";
}
}
?>





Vehicle Submission Form


List Your Vehicle













Scroll to Top