code,very,easy,teach,post,variables,simple,us
Quick Search for:  in language:    
code,very,easy,teach,post,variables,simple,us
   Code/Articles ╗ |  Newest/Best ╗ |  Community ╗ |  Jobs ╗ |  Other ╗ |  Goto ╗ | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
PHP Stats

 Code: 74,754 lines
 Jobs: 12 postings

 
Sponsored by:

 

You are in:

 
Login



Latest Code Ticker for PHP.
Smart Image Navigator
By Brian Di Croce on 10/27


Click here to see a screenshot of this code!Form security verification
By Christian Mallette on 10/26

(Screen Shot)

Click here to see a screenshot of this code!Guestbook
By Nightmare on 10/25

(Screen Shot)

Shout! Box
By Nightmare on 10/23


SERVER-TO-SERVE R site (or single dir) transfer
By Raffaele Marranzini on 10/22


Site IP Logger - Watch who comes to your site!
By KRaZY-DeSiGN on 10/21


IP Banner - Block unwanted people from your site!
By KRaZY-DeSiGN on 10/20


PWGen
By Flinn Mueller on 10/19


URHere
By Flinn Mueller on 10/19


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 
   

Easy to learn: [Calculator]

Print
Email
 
VB icon
Submitted on: 9/27/2002 7:33:37 PM
By: PWFilms  
Level: Beginner
User Rating: Unrated
Compatibility:PHP 3.0, PHP 4.0

Users have accessed this code 350 times.
 
(About the author)
 
     This code is a very easy way to teach you post variables and simple php. It uses math equasions, and its just overall a simple little calculator. You can check it out in action at <a href="http://www.paddedwallsfilms.com/php/project1-acipriano.php">this</a> location. Have fun.
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    //**************************************
    //     
    // Name: Easy to learn: [Calculator]
    // Description:This code is a very easy 
    //     way to teach you post variables and simp
    //     le php. It uses math equasions, and its 
    //     just overall a simple little calculator.
    //     You can check it out in action at <a 
    //     href="http://www.paddedwallsfilms.com/ph
    //     p/project1-acipriano.php">this</a&
    //     gt; location. Have fun.
    // By: PWFilms
    //
    //This code is copyrighted and has    // limited warranties.Please see http://
    //     www.Planet-Source-Code.com/xq/ASP/txtCod
    //     eId.754/lngWId.8/qx/vb/scripts/ShowCode.
    //     htm    //for details.    //**************************************
    //     
    
    <?php #start the php coding
    # check and see if our variables have been defined
    $n1 = $HTTP_POST_VARS['n1']; # this calls the variables 
    $n2 = $HTTP_POST_VARS['n2']; # from when you define them
    $do = $HTTP_POST_VARS['do']; # in the text boxes
    # check the value of the variable called "do" and calculate the variable based on what "do" says to do
    if($do == 'sum of') # this is what the do variable is
    	{
    		$answer = $n1 + $n2; # this adds the variables
    		$text = "The ".$do." ".$n1." and ".$n2." is <b>".$answer."</b>."; # this writes down the answer
    }
    if($do == 'difference between') # add a comment here
    {
    $answer = $n1 - $n2; #add a comment here
    $text = "The ".$do." ".$n1." and ".$n2." is
    <b>".$answer."</b>."; #add a comment here 
    }
    if($do == 'product of') # add a comment here
    {
    $answer = $n1 * $n2; #add a comment here
    $text = "The ".$do." ".$n1." and ".$n2." is
    <b>".$answer."</b>."; #add a comment here 
    }
    if($do == 'quotient of') # add a comment here
    {
    $answer2 = $n1 / $n2; #add a comment here
    $answer = round($answer2, 1);
    $text = "The ".$do." ".$n1." and ".$n2." is
    <b>".$answer."</b>."; #add a comment here 
    }
    if($do == 'exponent of') # add a comment here
    {
    $answer = bcpow($n1,$n2);
    $text = "The ".$do." ".$n1." and ".$n2." is
    <b>".$answer."</b>."; #add a comment here 
    }
    ?> 
    <html>
    	<head>
    		<title>Assignment 1: Reading the get vars and doing some calculations</title>
    	</head>
    		<body bgcolor=#787F87 text=black>
    <font face="Trebuchet MS" size="-1" color="black">
    			<br><br><br><br><center><table cellpadding='0' cellspacing='0' width='50%' height='30%' border=1 bordercolor=black>
    				<tr valign='center'>
    					<td align='center' bgcolor=#787F87 text=black border=1 bordercolor=black>
    						<!-- this page returns to itself via the POST method -->
    <!-- We use POST instead of get because with get, you can read the variables in the url -->
    						<form action='<?= $PHP_SELF; ?>' method='post'>
    						Find the 
    						<!-- Here we define the do so the php knows how to handle the inputed numbers -->
    						<select name='do'>
    							<option value='<?= $do; ?>'><?= $do; ?>
    							<option value='sum of'> sum of
    							<option value='difference between'> difference between 
    							<option value='product of'> product of
    							<option value='quotient of'> quotient of 
    							<option value='exponent of'> exponent of
    						</select> 
    						<!-- this is the text field which defines the number n1 -->
    						<input type=text size='2' max='4' name='n1' value='<?= $n1; ?>'> and 
    						<!-- this is the text field which defines the number n2 -->
    						<input type=text size='2' max='4' name='n2' value='<?= $n2; ?>'>.
    						<p>
    						<!-- this submits the information using the post tag above so we can compute the answer -->
    						<input type=submit name='submit' value='Do it!'>
    						<p>
    <font face="Trebuchet MS" size="-1" color="blue"><b>
    						<!-- this is the answer -->
    						<?= $text; ?></b></font>
    						</form>
    					</td>
    				</tr>
    			</table></center>
    	</body>
    </html>

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Beginner category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | PHP Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyrightę 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.