Question

In: Computer Science

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 up horizontally and all the
INPUTS/SELECT should line up horizontally.

Solutions

Expert Solution

Below is the solution:

shippingCost.php:

<?php

    //

    if(isset($_POST['submit'])){ //Calculate button click event

        $weight = $_POST['weight']; //take input from textbox

        if($weight == ""){ //check for the empty weight input box

            echo "<script type='text/javascript'>alert('Enter weight');</script>";

        }else{

            $shipping = 'Shipping cost is : $'. (.01 * $weight); //calculate the shipping cost by 0.01 per pound

        }

    }

    else if(isset($_POST['reset'])){ //reset button click event

        $shipping=""; //rest the shipping value

    }

?>

<!doctype html>

<head>

<meta charset="utf-8">

<title>Shipping Cost Calculator</title>

</head>

<style>

/* CSS Document */

body{

    font-family:Arial,Helvectica, san serif;

    width:40%;

    margin:0 auto;

}

</style>

<body>

        <h1>Shipping Cost Calculator</h1>

        <fieldset>

            <legend>Weight cost:</legend>

            <form action="shippingCost.php" method="post">

                <table>

                    <tr>

                        <td><label>Enter weight of the item (in pound):</label></td>

                        <td><input type="text" name="weight" size="10" maxlength="10" /></td>

                    </tr>

                    <tr>

                        <td></td>

                        <td><br>

                            <input type="submit" value="Calculate" name="submit"/>

                            <input type="submit" value="Reset" name="reset" />

                        </td>

                    </tr>

                    <tr>

                        <td><br><br>

                            <?php echo $shipping; //print the shipping cost?>

                        </td>

                    </tr>

                </table>

            </form>

        </fieldset>

</body>

</html>

sample output:

Enter 2000 pound and the cost is $20


Related Solutions

q1) using Matlab make a code that allows a user to enter a function like fractional...
q1) using Matlab make a code that allows a user to enter a function like fractional function and cubic liner function then the Matlab send a domain, range, continuity
q1) using Matlab make a code that allows a user to enter a function like fractional...
q1) using Matlab make a code that allows a user to enter a function like fractional function and cubic liner function then the Matlab send a domain, range, continuity
Make a function in C that allows for the user to enter in 2 separate strings....
Make a function in C that allows for the user to enter in 2 separate strings. The first string that is entered is then made equal to the second string, but any duplicate characters (the same character appearing twice or more in a row) should only be copied once to the output string. Lastly the function displays how many duplicate characters were found.
Using python, allows a user to enter the values of two, 3x3 matrices and then select...
Using python, allows a user to enter the values of two, 3x3 matrices and then select from options including, addition, subtraction, matrix multiplication, and element by element multiplication. You should use numpy.matmul()for matrix multiplication(e.g. np.matmul(a, b)).The program should computer the appropriate results and return the results, the transpose of the results, the mean of the rows for the results, and the mean of the columns for the results.When entering data you should check that each value is numeric for the...
USING PYTHON. Thank you in advance Write a program that allows the user to enter a...
USING PYTHON. Thank you in advance Write a program that allows the user to enter a series of string values into a list. When the user enters the string ‘done’, stop prompting for values. Once the user is done entering strings, create a new list containing a palindrome by combining the original list with the content of the original list in a reversed order. Sample interaction: Enter string: My Enter string: name Enter string: is Enter string: Sue Enter string:...
Using Pseudocode: Design a program that allows the user to enter 20 names into a String...
Using Pseudocode: Design a program that allows the user to enter 20 names into a String array. Sort the array in ascending (alphabetical) order and display its contents.
DATA STRUCTURES USING C++ 2ND EDITION Write a program that allows the user to enter the...
DATA STRUCTURES USING C++ 2ND EDITION Write a program that allows the user to enter the last names of five candidates in a local election and the votes received by that candidate. The program should then output each candidates name, votes received by that candidate, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. A sample output is as follow Johnson    5000 25.91 miller    4000   ...
Write a C++ program using dynamic arrays that allows the user to enter the last names...
Write a C++ program using dynamic arrays that allows the user to enter the last names of the candidates in a local election and the number of votes received by each candidate. The program must ask the user for the number of candidates and then create the appropriate arrays to hold the data. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should...
Create an application that allows the user to enter the total for an order and the...
Create an application that allows the user to enter the total for an order and the name of the customer. If the order is less than 500 dollars, the customer gets no discount. If the order is greater than or equal to 500 and less than 1000 dollars, the customer gets a 5 percent discount. If the order is greater than or equal to 1000 dollars, the customer gets a 10 percent discount. The application should display the name of...
Using Visual Studio write a program that allows the user to enter multiple scores ranging from...
Using Visual Studio write a program that allows the user to enter multiple scores ranging from 0 to 100, computes the average of those scores and then writes out a letter grade using the typical grading scale. Your program will also: 1. Allow the user to enter any number of scores he or she wishes but assume there will be at least one score entered. 2. Use a sentinel-controlled loop variable to terminate the loop when the user has no...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT