These things are always popular with everyone, so I decided to code one to try to make my hunger pains go away... This uses a the rand(); function and echo's an appropriate message to their number.
It's entriely self contained.
Fixed all errors, see it in action at http://tazroger.net/edd/lovecalc.php.PHP Code:<?php
//LOVE CALCULATOR!!!
echo("
<font size=\"2\" face=\"Verdana\">
<form method=\"POST\">
Your Name: <input type=\"text\" name=\"name1\">
<br />
Crushes Name: <input type=\"text\" name=\"name2\">
<br />
<input type=\"submit\" value=\"Calculate\">
</form>
");
//Woo. So now we choose what to do if the forms sent.
$name1 = $_POST['name1']; // The "Your Name:" variable.
$name2 = $_POST['name2']; // The "Crushes Name:" variable.
if(!$name1){ exit(); }
$rand = rand(1,99); // Uses the rand(); function in PHP to make a number between 1 and 99
echo("<b>$name1</b> and <b>$name2</b>'s love rating is <b>$rand</b>.<br />"); // Result. We've echoed it. Now we'll do a "Cupids Comment" thing.
if($rand <= "20"){
echo("Cupids Comment: Face it, it's not gonna work out between the two of you!");
}
if($rand <= "40" && $rand >= "21"){
echo("Cupids Comment: There could be love between you two, but then again, maybe not.");
}
if($rand <= "60" && $rand >= "41"){
echo("Cupids Comment: Try it and see, there's about a 50/50 chance.");
}
if($rand <= "80" && $rand >= "61"){
echo("It's likely, the chances of the spark going are preety slim.");
}
if($rand <= "99" && $rand >= "81"){
echo("Cupids Comment: There's almost definiatley love there! Go ahead. Your not gonna be heartbroken.");
}
echo("</font>");
?>

