HTML Form POST to PHP page [closed]

Marc Towler is correct. You need to have the page with the extension of PHP for PHP code to be parsed in the first place. But I’d actually suggest you separate the pages of your form and your form processing. I’d suggest the following:

myform.php:

<!DOCTYPE html>
<html>
<head></head>
<body>   
<div class="content">
    <form action="formprocessor.php" method="POST">
        <label>Name: </label>
        <input name="name" type="text" size="25" />

        <label>Course: </label>
        <input name="course" type="text" size="25" />

        <label>Book: </label>
        <input name="book" type="text" size="255" />

        <label>Price: </label>
        <input name="price" type="text" size="7" />

        <label>Email: </label>
        <input name="email" type="text" size="255" />

        <label>Phone #: </label>
        <input name="phone" type="text" size="12" />

        <input name="mySubmit" type="submit" value="Submit!" />
    </form>
</div>
</body>
</html>

formprocessor.php:

<?php
$name = $_POST["name"];
$course = $_POST["course"];
$book = $_POST["book"];
$price = $_POST["price"];
$email = $_POST["email"];
$phone = $_POST["phone"];

echo $name;
?>

Leave a Comment