Week Five PHP

rocks

8:31:08 pm, Friday, November 21, 2008

We want to know!

dwarf

Your Name: 


Who is the coolest Dwarf?

  Bashful
  Doc
  Dopey
  Grumpy
  Happy
  Sleepy
  Sneezy


Week 1 Week 2 Week 3 Week 4 Week 5 Week 6

<?php
if (isset ($_COOKIE["dwarfpoll"])) {
include (
"header.inc");
echo 
"<div class='shortstuff'><img src='images/oops.gif' alt='oops' title='oops' width='195' height='275'/><br />
I'm sorry, you've already voted you crazy cat!</div>"
;
include (
"footer.inc");
exit;
}
?>
<?php
//Read variables
$name $_POST["name"];
$dwarf $_POST["dwarf"];

if (!empty(
$name)) {
   
setcookie("dwarfpoll""yes"time()+60);
   switch (
$dwarf) {
     case 
Bashful:
         
$message "<div class='shortstuff'><img src='images/bashful.png' alt='bashful' title='bashful' width='190' height='235'/><br />
         Hello, $name. Bashful is afraid to say he didn't have a clue in lesson four.</p>"
;
         break;
     case 
Doc:
         
$message "<div class='shortstuff'><img src='images/doc.png' alt='doc' title='doc' width='160' height='267'/><br />
         Hello, $name. Doc wears glasses (so presumably the most intellectual). He is probably our teach!"
;
         break;
     case 
Dopey:
         
$message "<div class='shortstuff'><img src='images/dopey.png' alt='dopey' title='dopey' width='190' height='246'/><br />
         Hello, $name. Dopey's code comes out crazy every time!."
;
         break;
     case 
Grumpy:
         
$message "<div class='shortstuff'><img src='images/grumpy.png' alt='grumpy' title='grumpy' width='225' height='217'/><br />
         Hello, $name. Grumpy is grouchy and curmudgeonly from working on lesson 4 in php class:p"
;
         break;
     case 
Happy:
         
$message "<div class='shortstuff'><img src='images/happy.png' alt='happy' title='happy' width='160' height='242'/><br />
         Hello, $name. Happy the most rotund of the dwarfs. That's why he's happy! (that and his php code worked)"
;
         break;    
     case 
Sleepy:
         
$message "<div class='shortstuff'><img src='images/sleepy.png' alt='sleepy' title='sleepy' width='220' height='158'/><br />
         Hello, $name. Sleepy wears a perpetually sleepy looking expression from those long hours in php class."
;
         break;
     case 
Sneezy:
         
$message "<div class='shortstuff'><img src='images/sneezy.png' alt='sneezy' title='sneezy' width='160' height='256'/><br />
         Hello, $name. Sneezy hasn't got a prayer, he's allergic to php ;)"
;
         break;         
     default:
         
$message "<div class='shortstuff'><img src='images/sadface.gif' alt='sad' title='sad' width='193' height='232'/><br />
         Hello, $name. Sorry you didn't choose a dwarf."
;
      }
  include (
"header.inc");      
  echo 
$message
  echo 
"<p>Thank you for participating in our poll.</p></div>";
} else {
include (
"header.inc");
include (
"form.inc");
}
?>
</div>

<?php
include ("footer.inc");
?>