VB icon

Sum of Two Numbers in CodeIgniter

Email
Submitted on: 12/13/2015 2:52:50 AM
By: Jake R. Pomperada  
Level: Beginner
User Rating: By 1 Users
Compatibility: PHP 5.0
Views: 8246
author picture
 
     A sample program that I wrote using CodeIgniter one of the most popular PHP framework. What does the program will do is to ask the user to give to numbers and then our program will give the sum of the two numbers. If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. My mobile number here in the Philippines is 09173084360.

 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
//**************************************
// Name: Sum of Two Numbers in CodeIgniter
// Description:A sample program that I wrote using CodeIgniter one of the most popular PHP framework. What does the program will do is to ask the user to give to numbers and then our program will give the sum of the two numbers.
If you have some questions please send me an email at jake.r.pomperada@gmail.com and jakerpomperada@yahoo.com. 
My mobile number here in the Philippines is 09173084360.
// By: Jake R. Pomperada
//**************************************

<?php
error_reporting(0);
class sum_two_numbers extends CI_Controller
{
function index()
{
echo "<html>";
echo "<head>";
echo " <title>Sum of Two Numbers in CodeIgniter</title>";
echo "</head>";
echo "<style>";
echo "body {";
echo "font-family:arial;";
echo "}";
echo "</style>";
echo "<body>";
if(isset($_POST['submit'])){
$num1 = $_POST['num1'];
$num2 = $_POST['num2'];
$result = $num1 + $num2;
}
if(isset($_POST['clear'])){
$num1 = "";
$num2 = "";
$result = "";
 }
echo "<form action='' method='post' name='myform' align='center'>";
echo "<h3>Sum of Two Numbers in CodeIgniter </h3>";
echo "<br>";
echo "Enter number 1:   <input type='text' name='num1' autofocus='true' value=$num1 > ";
echo "<br>";
echo "Enter number 2:   <input type='text' name='num2' value=$num2>";
echo "<br><br>";
echo "<input type='submit' name='submit' value='Sum' ";
echo "title='Click here to find the sum of two numbers.' />";
echo "   ";
echo "<input type='submit' name='clear' value='Clear'";
echo "title='Click here to clear the text boxes.' />";
echo "</form>";
echo "<br>";
echo "<table border='1' align='left'>"; 
echo "<td align='center'>Value No. 1</td>";
echo "<td align='center'>Operator</td>";
echo "<td align='center'>Value No. 2</td><td align='center'>Total Sum";
echo "</td></tr>";
echo "<tr><td align='center'>";
echo $num1;
echo "</td><td align='center'>+";
echo "</td><td align='center'>";
echo $num2;
echo "</td><td align='center'>";
echo $result;
echo "</td></tr>";
echo "</table>";
 }
}
?>


Other 52 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

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
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.