Skip to content
PHP Logo

What are some common methods for receiving form data in PHP without sending an email?

When receiving form data in PHP without sending an email, you can use methods such as processing the form data within the same PHP file, storing the data in a database, or redirecting to another page with the form data in the URL parameters. This allows you to handle the form submission without the need to send an email.

php
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    // Process form data here
    $name = $_POST['name'];
    $email = $_POST['email'];
    
    // Store data in a database
    // Example: Assuming you have a database connection
    $sql = "INSERT INTO users (name, email) VALUES ('$name', '$email')";
    mysqli_query($conn, $sql);

    // Redirect to another page with form data in URL parameters
    header("Location: thank-you.php?name=$name&email=$email");
    exit;
}
?>