Question

In: Computer Science

Using PHP, Create a form that uses the method POST to send the information. The form...

Using PHP, Create a form that uses the method POST to send the information. The form should capture the distance the package needs to travel with the one field for the distance in miles.
All fields should have the REQUIRED attribute.
The form should have a submit button and reset button.
The form should look nice. All the labels should line up horizontally and all the
INPUTS/SELECT should line up horizontally.

Solutions

Expert Solution

<html>
<head>
<style>
.error {color: #FF0000;}
</style>
</head>
<body>

<?php
  
$distanceErr = $originError = $primeError = $destinationError = "";
$distance = $origin = $prime = $specialInstructions = $destination = "";

if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["distance"])) {
$distanceErr = "distance is mandatory";
}
  
if (empty($_POST["origin"])) {
$originErr = "origin is mandatory";
}
  
if (empty($_POST["destination"])) {
$destinationError = "destination is mandatory";
}

if (empty($_POST["prime"])) {
$primeError = "Please select delivery type";
}
}
?>

<h2>Package Handler</h2>
<p><span class="error">* required field</span></p>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<table>
<tr>
<td>
Package Distance:
</td><td><input type="text" name="distance" value="<?php echo $distance;?>">
<span class="error">* <?php echo $distanceErr;?></span>
</td></tr>
  
<tr>
<td>
Origin:</td>
<td><input type="text" name="origin" value="<?php echo $origin;?>">
<span class="error">* <?php echo $originError;?></span>
</td></tr>
<tr>
<td>
Destination:
</td>
<td><input type="text" name="destination" value="<?php echo $destination;?>">
<span class="error"><?php echo $destinationError;?></span>
</td>
</tr>
<tr>
<td>Special Instructions:</td>
<td><textarea name="specialInstructions" rows="5" cols="40"><?php echo $specialInstructions;?></textarea>
</td></tr>
<tr><td>Prime Delivery:</td>
<td><input type="radio" name="prime" value="Yes">Yes
<input type="radio" name="prime" value="No">No
<span class="error">* <?php echo $primeError;?></span>
</td></tr>
<tr><td colspan="2" style="text-align:center;">
<input type="submit" name="submit" value="Submit"></td></tr>
</table>
</form>
</body>
</html>


Related Solutions

Using PHP and MySQL Create a simple web form with at least 5 fields Include validation...
Using PHP and MySQL Create a simple web form with at least 5 fields Include validation and error messages Create a MySQL Database Create a table to store submissions from the form Only insert new data into the database when all validation is passed Use PHP to create an HTML table showing all the content of the database   New submissions should appear in table
- Create an html form (bank form) and the PHP code with 2 accounts with options...
- Create an html form (bank form) and the PHP code with 2 accounts with options to transfer, deposit or withdraw money.
1. PHP OOP Create a complete PHP enabled website that defines and uses a PineApple class...
1. PHP OOP Create a complete PHP enabled website that defines and uses a PineApple class in PHP. The class has following members. Properties $color: string type $taste: string type $weight: number type Standard constructor, with 3 parameters Member functions eat(): no return, no parameter, print a short paragraph in English to describe how to eat a pineapple. grow(): no return, no parameter, print a short paragraph in English to describe how to grow a pineapple plant. display(): no return,...
Create a web page using PHP that allows the users to create an account (a username...
Create a web page using PHP that allows the users to create an account (a username and a password). There should be a login page that allows users to create an account by entering their preferred username and password. The same page should also let users login if they already have an account. If a user is logged in successfully , they should be able to enter a comment and also read the comments entered by others previously.
Using PHP, Make a form that allows the user to enter the weight of the item...
Using PHP, Make a form that allows the user to enter the weight of the item being shipped. This will be used to calculate the shipping cost.Create a form that uses the method POST The form should capture a customer's package weight with the one field for the package weight in pounds. All fields should have the REQUIRED attribute. The form should have a submit button and a reset button. The form should look nice. All the labels should line...
Using PHP and MYSQL and with a simple customer database, how can I create a simple...
Using PHP and MYSQL and with a simple customer database, how can I create a simple log in and registration system for an ecommerce site
Create a web page using PHP and HTML that contains a list of movie names available...
Create a web page using PHP and HTML that contains a list of movie names available for rent (at least 10 movies), so that each time you visit the home page, you see a different order of movies in the list. The movie names are required. 2) The rental price for each movie ranges between $1.99 to $7.99. • Create an associative array with a code for the movie as the key (e.g., movie1, movie2, etc.) and the associated rental...
2. Create a php program to get all the values from the forms using various methods...
2. Create a php program to get all the values from the forms using various methods and control structures like switch, if else, for, foreach, while, do while The question is required to write a program
PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML...
PHP Question - Subject: PHP File Handling and Uploads INSTRUCTIONS: Objective: • Create a sticky HTML form. • Submit form for processing. • Sanitize and validate form data. • Upload a profile image. • Add a record to a text file. • Display form results with content from another text file and the uploaded image. Description: This assignment deals with file management. It requires the use of 3 new files and 1 new directory. You will create the new file-uploads.php...
PHP    1. Create a new PHP document (nit Objective 1)    2. Write a comment...
PHP    1. Create a new PHP document (nit Objective 1)    2. Write a comment similar to the following: "This is my first PHP document, which displays some data in the web browser"(Unit Objective 1)    3. Assign your name as a string value into the variable labeled myName (Unit Objective 2)    4. Assign 53870 numeric value into the variable named randomNumber (Unit Objective 2) 5. ssign the name of the web browser and operating system of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT