Well; I'm currently taking a PhP/MySQL programming class, and I'm curious if I've done an assignment correctly:
"Create a php script that will process and print a form. The form will take as input a person's first and last name, and an e-mail address. The form (when the submit button is pressed) will then output the persons name and a message that will state that e-mail has been sent to them. You are not sending e-mail of course, this is just a practice for later projects."
Now; this is what I created for this assignment:
HTML Code:
Code:
<html>
<head>
<title>E-mail Submission</title>
</head>
<body>
<center>
<form method = "post"
action = "mainPHP.php">
Please type your first name:
<input type = "text"
name = "firstName">
<br>
<br>
Please type your last name:
<input type = "text"
name = "lastName">
<br>
<br>
Pleast type you E-mail Address:
<input type = "text"
name = "email">
<br>
<br>
<input type = "submit" />
</center>
</form>
</body>
</html>
^^ I used above as merely a simple HTML script obviously, the following is the PhP script:
Code:
<?php
$firstName = $_POST['firstName'];
$lastName = $_POST['lastName'];
$email = $_POST['email'];
echo "Hello $firstName $lastName, the E-mail was sent to $email. ";
?>
The code works as I want it to, however, the assignment is for one PHP script, and from what I've read in the book, it only explains using two files to complete this type of project.
The question is, can I create the same thing, with only one PHP code?
|