Jump to content

Calculating A Form


MjM8082

Recommended Posts

Not asking someone to do this for me. Just looking for someone to help me get going, and show me how to do this.

 

 

Need helping calculating text boxes on a form. I want my form to display the premium of $10,000 health insurance. What I mean by this is that I have a form that involves filling out life insurance information.

 

This is the table I'm basing this off of...

 

                                                    Age <=30

#health conditions <=2                  $0.90

2 <= #health conditions <=5          $1.20

 

 

 

The number of health conditions is equivalent to the number of check boxes that were checked. Additionally,

the following conditions apply:

 

- Men are charged a 5% gender risk

- Students receive an 8% discount

 

For example, if you are a 23 year old male student who smokes but has no other risk factors your

premium amount per $10,000 would be $0.90 * 1.05 * 0.92 = $0.8694. If you wanted to take out a

$150,000 life insurance, your monthly premium would be $13.04 (15 * $0.8694).

 

 

 

I'm new to php and haven't really calculated forms before...

 

 

here is my form codes....

 

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
    <title>Lab 4</title>
    
</head>


<body>
    <?php


?>



<form method="POST" action="lab4form.php">		

<label for="first_name">First Name:</label>
<input type="text" id="first_name" name="first_name" /><br />		
<label for="last_name">Last Name:</label>
<input type="text" id="last_name" name="last_name" /><br />	
<label for="coverage_amount">Coverage Amount:</label> 
<input type="text" id="coverage_amount" name="coverage_amount" /><br />	
<label for="gender">Gender:</label>
<br>
<input id="male" type="radio" value="Male" name="gender" />
	<label for="male">Male</label> 

<input id="female" type="radio" value="Female" name="gender" />
	<label for="female">Female</label> <br />
	<br>
<label for="Age">Age:</label>
<input type="text" id="age" name="age" /><br />	
<br>
<label for="health">Health Conditions</label> <br />

<input type="checkbox" name="health" value="Heart Disease" />
<label for="health">Heart Disease</label><br />

<input type="checkbox" name="health" value="Diabetes" />
<label for="health">Diabetes</label><br />

<input type="checkbox" name="health" value="High Blood Pressure" />
<label for="health">High Blood Pressure</label><br />

<input type="checkbox" name="health" value="Smoker" />
<label for="health">Smoker</label><br />

<input type="checkbox" name="health" value="Lung Disease" />
<label for="health">Lung disease</label><br />

<FORM METHOD=POST ACTION="lab4form.php">
<P>Employment Status<BR>
<SELECT NAME="employment">
<OPTION VALUE="Unemployed">Unemployed
<OPTION VALUE="Full-Time">Full-Time
<OPTION VALUE="Part-Time">Part-Time
<OPTION VALUE="Student">Student
</SELECT><br />
<br>
<label for="comments">Comments</label>
<input type="text" id="comments" name="comments"/><br />






<br>
<input type="submit" value="Add User" name="btn_add" />			
</form> 
</body>
</html>

 

Link to comment
Share on other sites

nope right now I don't need a database, what I'm trying to do is make everything display on the next page in a table.

 

here is the form page a long with the table page...

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


<head>
    <title>Lab 4</title>
    
</head>


<body>
    <?php


?>



<form method="POST" action="lab4form.php">		

<label for="first_name">First Name:</label>
<input type="text" id="first_name" name="first_name" /><br />		
<label for="last_name">Last Name:</label>
<input type="text" id="last_name" name="last_name" /><br />	
<label for="coverage_amount">Coverage Amount:</label> 
<input type="text" id="coverage_amount" name="coverage_amount" /><br />	
<label for="gender">Gender:</label>
<br>
<input id="male" type="radio" value="Male" name="gender" />
	<label for="male">Male</label> 

<input id="female" type="radio" value="Female" name="gender" />
	<label for="female">Female</label> <br />
	<br>
<label for="Age">Age:</label>
<input type="text" id="age" name="age" /><br />	
<br>
<label for="health">Health Conditions</label> <br />

<input type="checkbox" name="health" value="Heart Disease" />
<label for="health">Heart Disease</label><br />

<input type="checkbox" name="health" value="Diabetes" />
<label for="health">Diabetes</label><br />

<input type="checkbox" name="health" value="High Blood Pressure" />
<label for="health">High Blood Pressure</label><br />

<input type="checkbox" name="health" value="Smoker" />
<label for="health">Smoker</label><br />

<input type="checkbox" name="health" value="Lung Disease" />
<label for="health">Lung disease</label><br />

<FORM METHOD=POST ACTION="lab4form.php">
<P>Employment Status<BR>
<SELECT NAME="employment">
<OPTION VALUE="Unemployed">Unemployed
<OPTION VALUE="Full-Time">Full-Time
<OPTION VALUE="Part-Time">Part-Time
<OPTION VALUE="Student">Student
</SELECT><br />
<br>
<label for="comments">Comments</label>
<input type="text" id="comments" name="comments"/><br />






<br>
<input type="submit" value="Add User" name="btn_add" />			
</form> 
</body>
</html>

 

 

 

Table page...

 

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

    

    <head>

        <title>Lab4</title>

        

    </head>

    <body>

    <div id="page">

        <div id="main">






        <div id="content">

            

            <h2>Life Insurance</h2>

            <table>

                <tr>

                    <th>Coverage Amount</th>

                    <th>Name</th>

                    <th>Gender</th>

				<th>Age</th>

				<th>Health Conditions</th>

				<th>Employment Status</th>

				<th>Comments</th>


                </tr>

                                <tr>

                    <td><?php echo $_POST['coverage_amount'];?></td>

                    <td><?php echo $_POST['first_name'];?></td>

                    <td><?php echo $_POST['gender'];?></td>

				<td><?php echo $_POST['age'];?></td>

				<td class="right"><?php echo $_POST['health'];?></td>

				<td class="right"><?php echo $_POST['employment'];?></td>

				<td><?php echo $_POST['comments'];?></td>

                </tr>

                 

                            </table>

        </div>

        </div>

        <div id="footer"></div>

    </div>

    </body>

</html>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.