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...
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   ...
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...
Write a program that runs on SPIM that allows the user to enter the number of...
Write a program that runs on SPIM that allows the user to enter the number of hours, minutes and seconds and then prints out the total time in seconds. Name the source code file “seconds.asm
Write a program that runs on SPIM that allows the user to enter the number of...
Write a program that runs on SPIM that allows the user to enter the number of hours, minutes and seconds and then prints out the total time in seconds. Name the source code file “seconds.asm Explain step by step
Write out code for a nested if statement that allows a user to enter in a...
Write out code for a nested if statement that allows a user to enter in a product name, store the product into a variable called product name and checks to see if that product exists in your nested if statement. You must include 5 product names to search for. If it is then assign the price of the item to a variable called amount and then print the product name and the cost of the product to the console. If...
Write an application that allows a user to enter the names and birthdates of up to...
Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. When the user is finished entering names, produce a count of how many names were entered, and then display the names. In a loop, continuously ask the user to type one of the names...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT