Two page mobile magic 8-ball

Had to use random numbers to prevent caching of pages by mobile web browsers. It’s entirely possible that I made this workaround too complicated, as I had a file version problem on my local drive (I was updating the wrong file.)

The first page uses a random number in a hidden field with the POST method:

Magic 8-ball

Ask your question, and click the button for an answer.
echo "
";
?>

The second page appends a random number to the URL:

?>
Magic 8-Ball
$responses = array(
"As I see it, yes",
"It is certain",
"It is decidedly so",
"Most likely",
"Outlook good",
"Signs point to yes",
"Without a doubt",
"Yes",
"Yes - definitely",
"You may rely on it",
"Reply hazy, try again",
"Ask again later",
"Better not tell you now",
"Cannot predict now",
"Concentrate and ask again",
"Don't count on it",
"My reply is no",
"My sources say no",
"Outlook not so good",
"Very doubtful");
?>

Magic 8-ball

$selection = rand(0, count($responses)-1);
?>

The magic 8-ball says:

echo "[".$responses[$selection]."]";
echo "

";
echo "Ask another question";

?>


Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • StumbleUpon
  • Tumblr
  • TwitThis
  • FriendFeed
  • Netvibes
  • Ping.fm
  • Posterous
  • Technorati
  • Tipd
  • Twitter
  • Yahoo! Buzz