PHP: Form with a separate php script file

This entry is part 42 of 54 in the series PHP Tutorial

As mentioned in the earliar example, we can put the php script in a separate file.


<form action="form4.php" method="post">
    Name: <input type="text" name="name"><br>
    E-mail: <input type="text" name="email"><br>
    <input type="submit">


Below here the separate php script file.

$your_name = $_POST["name"];
$your_email = $_POST["email"];
echo "Welcome " . $your_name."<br>";
echo "Your Email is " . $your_email; ?>

You can try to run the page here.

The warning would not have been generated if we have 2 separate files.

Put the form.html and form4.php in the same directory, run the form.html above and it will call out the form4.php in a different file.

Series Navigation<< PHP: A simple form with validation
PHP: htmlspecialchars() >>