Week 9-10 Question 9 - PHP Online
Form of PHP Sandbox
Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php
in the places where the PHP script should be executed.
Result of php executing
Full code of Week 9-10 Question 9.php
- <!DOCTYPE HTML>
- <html>
- <body>
- <?php
- $name = $room = $in_name = $in_email = "";
- $nameErr = $roomErr = $in_nameErr = $in_emailErr = "";
- if ($_SERVER["REQUEST_METHOD"] == "POST") {
- if (empty($_POST["name"])) {
- $nameErr = "Name is required";
- } else {
- $name = test_input($_POST["name"]);
- }
- if (empty($_POST["email"])) {
- $in_emailErr = "Email is required";
- } else {
- $in_email = test_input($_POST["email"]);
- }
- if (empty($_POST["room"])) {
- $roomErr = "Room number required";
- } else {
- $room = test_input($_POST["website"]);
- }
- if (empty($_POST["instructors name"])) {
- $in_nameErr = "intructors name required";
- } else {
- $in_name = test_input($_POST["intructors name"]);
- }
- }
- ?>
- <form method="POST" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
- Course Name: <input type="text" name="name" value="<?php echo $name;?>"><br>
- Room Number: <input type="text" name="room number" value="<?php echo $room;?>"><br>
- Instructors Name: <input type="text" name="instructors name" value="<?php echo $in_name;?>"><br>
- Instructors E-mail: <input type="text" name="instructors email" value="<?php echo $in_email;?>"><br>
- <input type="submit">
- </form>
- <?php
- echo "Welcome $in_name to the following Course $name, in room $room, and email $in_email";
- ?>
- </body>
- </html>
File Description
- Week 9-10 Question 9
- PHP Code
- 07 Apr-2021
- 1.29 Kb
You can Share it:
Latest PHP Pastes