How can a date be stored in a MySQL table when a form is submitted, similar to eBay's listing expiration feature?

To store a date in a MySQL table when a form is submitted, similar to eBay's listing expiration feature, you can use a combination of PHP and MySQL. You can create a column in your table to store the expiration date, then calculate the expiration date based on the current date and the desired expiration period (e.g., 7 days). When the form is submitted, capture the current date, calculate the expiration date, and insert it into the database along with other form data.

// Assuming you have a connection to your MySQL database

// Get the current date
$currentDate = date('Y-m-d H:i:s');

// Calculate the expiration date (e.g., 7 days from the current date)
$expirationDate = date('Y-m-d H:i:s', strtotime($currentDate . ' + 7 days'));

// Assuming $formData contains the form data submitted
// Insert the form data along with the expiration date into the database
$query = "INSERT INTO your_table_name (column1, column2, expiration_date) VALUES ('$formData[value1]', '$formData[value2]', '$expirationDate')";
$result = mysqli_query($connection, $query);

if ($result) {
    echo "Form data and expiration date stored successfully.";
} else {
    echo "Error storing form data and expiration date: " . mysqli_error($connection);
}