I have a web form that I want to save to an XML file and send the information as an email. But the code in some way feels repetitive. Is there any more efficient way?
webform.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;
?>
First I need to define the name in the input.
Then the same name in the post formprocessor.php
Assign it to a variable
Use the variable to mail and XML
I have to do this 30 times (30 fields) with copy paste code but different name.