Monday, September 19, 2016

Add two number with for loop php code


<body>
<form action="" method="post">

<input type="text" name="n1" />
<input type="text" name="n2" />
<input type="submit" name="go" value="calculate" />

</form>
</body>

<?php

if(isset($_POST['go'])){

$num1=$_POST['n1'] ;
$num2=$_POST['n2'] ;

for($i=1; $i<=$num2; $i++){
$num1++;
}

    echo $num1;
}

?>

No comments:

Post a Comment