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.
Sample Program Output
Program Listing
<?php
// create a file named "sum.php" and then save the file in the
// following path in CodeIgniter example below
// "C: /xammp/htdocs/Demo/application/controllers"
// To run the application follow the commands below
// http://localhost/ci/index.php/sum
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>";
}
}
?>
// following path in CodeIgniter example below
// "C: /xammp/htdocs/Demo/application/controllers"
// To run the application follow the commands below
// http://localhost/ci/index.php/sum
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>";
}
}
?>