Hello everyone.
I tried to find out wether a number is armstrong or not.My logic was right but few php errors are creeping.I am new to PHP.So please help me out.
Here is the code
armstrong.php
<html>
<head>
<title>
Armstrong number
</title>
</head>
<body>
<?php
$arm=0;
$i;
$k;
$i=$_POST["i"];
$j=$i;
while($j!=0)
{
$k=$j%10;
$arm=$arm+($k*$k*$k);
$j=$j/10;
}
if($i==$arm)
{echo "Yes it is an Armstrong number";}
else
{echo "No,it is not an Armstrong Number";}
?>
<form method="POST" action="armstrong.php">
<input type="text" name="i" />
<br>
<br>
<input type="submit" name="submit" />
<input type="reset" name="reset" />
</form>
</body>
</html>
The error is it shows "Yes it is an Armstrong number" by default when we open armstrong.php in browser.And when we enter a number and click submit,every thing goes fine.
Here is a screenshot of it.
<hr>
And also some php errors are visible(undefined variable.....).
Please help.