elseif ((!ereg("[0-9]",$score_1)) || (!ereg("[0-9]",$score_2) || (!ereg("[0-9]",$score_3))))
I made a calculator that works; however i do not under stand the "( )" count. Hopefully you can point it out by explaining. Help is greatly appreciated.
This is the complete code:
<html>
<body bgcolor="#ffff33">
<?php
if ($submit)
{
$score_1=$_POST['score_1'];
$score_2=$_POST['score_2'];
$score_3=$_POST['score_3'];
if (($score_1 == "") || ($score_2 =="") || ($score_3 ==""))
{
echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Go play some more freegumph! Need at least three scores to calculate a handicap.</b></font><br>");
}
elseif ((!ereg("[0-9]",$score_1)) || (!ereg("[0-9]",$score_2) || (!ereg("[0-9]",$score_3))))
{
echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>You must be a new player. Freegumph scores only consist of numeric values.</b></font><br>");
}
elseif (($score_1 < 0) || ($score_2 < 0) || ($score_3 < 0))
{
echo("<font face=\"Tahoma\" size=\"2\" color=\"#006600\"><b>Error! Perhaps the lowest possible score is 0.</b></font><br>");
}
else
{
$avg=($score_1 + $score_2 + $score_3)/3;
if ($avg >= 27)
{
$total = 0;
}
else
{
$total = ((27- $avg) * (7/10));
}
print(" The freegumpher handicap is: ". $total);
}
}
?>
<form method="post" action="">
Enter your three most <i>recent</i> Freegumpher scores to calculate Handicap:<br/> <br/>
<input type="text" name="score_1" size=8
<input type="text" name="score_2" size=8
<input type="text" name="score_3" size=8 />
<br/>
<input type="submit" name="submit" value="Calculate Handicap"/>
</form>
</body>
</html>
I made a calculator that works; however i do not under stand the "( )" count. Hopefully you can point it out by explaining. Help is greatly appreciated.
This is the complete code:
<html>
<body bgcolor="#ffff33">
<?php
if ($submit)
{
$score_1=$_POST['score_1'];
$score_2=$_POST['score_2'];
$score_3=$_POST['score_3'];
if (($score_1 == "") || ($score_2 =="") || ($score_3 ==""))
{
echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>Go play some more freegumph! Need at least three scores to calculate a handicap.</b></font><br>");
}
elseif ((!ereg("[0-9]",$score_1)) || (!ereg("[0-9]",$score_2) || (!ereg("[0-9]",$score_3))))
{
echo("<font face=\"Tahoma\" size=\"2\" color=\"#FF0000\"><b>You must be a new player. Freegumph scores only consist of numeric values.</b></font><br>");
}
elseif (($score_1 < 0) || ($score_2 < 0) || ($score_3 < 0))
{
echo("<font face=\"Tahoma\" size=\"2\" color=\"#006600\"><b>Error! Perhaps the lowest possible score is 0.</b></font><br>");
}
else
{
$avg=($score_1 + $score_2 + $score_3)/3;
if ($avg >= 27)
{
$total = 0;
}
else
{
$total = ((27- $avg) * (7/10));
}
print(" The freegumpher handicap is: ". $total);
}
}
?>
<form method="post" action="">
Enter your three most <i>recent</i> Freegumpher scores to calculate Handicap:<br/> <br/>
<input type="text" name="score_1" size=8
<input type="text" name="score_2" size=8
<input type="text" name="score_3" size=8 />
<br/>
<input type="submit" name="submit" value="Calculate Handicap"/>
</form>
</body>
</html>