Help combining html file with php file deals with if else, filter_has_var

I am in a basic PHP class, trying to work ahead to make sure I can complete all the assignments in the 8 week summer semester. The book asks me to combine an html file with a php file from a previous chapter, its like a nursery rhyme modified, I have gotten this far and need some help please[code]

Story

Story

[/code] [php]<?php if (filter_has_var(INPUT_POST, "bName")); (filter_has_var(INPUT_POST, "gName")); (filter_has_var(INPUT_POST, "bPart")); (filter_has_var(INPUT_POST, "device")); { //form exists so it will appear first $bName = filter_input(INPUT_POST, "bName"); $gName = filter_input(INPUT_POST, "gName"); $bPart = filter_input(INPUT_POST, "bPart"); $device = filter_input(INPUT_POST, "device"); print "

$bName and $gName
Went up the hill
To Fetch a $device of water
$bName fell down and broke his $bPart
And $gName came tumbling after.

\n";

} else {

//create form for the input
print <<<HERE

Please fill in the blanks below, and I'll tell you a story

Boys Name: Girls Name body part
<label>water holding device </label>
bucket cooler glass sip Tell me the story HERE;

} // end if

?>[/php]

I know I shouldn’t have, for it feels like cheating ;D
[php]

Untitled Document <?php if (filter_has_var(INPUT_POST, "bName") && filter_has_var(INPUT_POST, "gName") && filter_has_var(INPUT_POST, "bPart") && filter_has_var(INPUT_POST, "device")) {

$bName = filter_input(INPUT_POST, “bName”);
$gName = filter_input(INPUT_POST, “gName”);
$bPart = filter_input(INPUT_POST, “bPart”);
$device = filter_input(INPUT_POST, “device”);
print <<<EOT

$bName and $gName
Went up the hill

To Fetch a $device of water
$bName fell down and broke his $bPart
And $gName came tumbling after. \n EOT; } else { //create form for the input print <<<EOT

Please fill in the blanks below, and I will tell you a story

Boys Name:

Girls Name

body part

water holding device

bucket cooler glass sip Tell me the story EOT; } // end if

?>

[/php]

Though it still has a few kinks in it…

Not cheating I am working ahead in my textbook, doing some things that the teacher will not even require this semester, so its not cheating I promise… and I will learn … thank you so much my friend :-*

At the bottom you put that… what does that do ???

[code]<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”

http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

Story <link rel = "stylesheet"

type = “text/css”

href = “story.css” />

Story

[/code] [php] <?php

if(filter_has_var(INPUT_POST, “bName”)) {

if (filter_has_var(INPUT_POST, "gName")) {

    if(filter_has_var(INPUT_POST, "bPart")) {

        if(filter_has_var(INPUT_POST, "device")))  {

            //all condition matched

        }

    }

}

//form exists so it will appear first

$bName = filter_input(INPUT_POST, “bName”)

$gName = filter_input(INPUT_POST, “gName”)

$bPart = filter_input(INPUT_POST, “bPart”)

$device = filter_input(INPUT_POST, “device”);

print "

$bName and $gName
Went up the hill

To Fetch a $device of water $bName fell down and broke his $bPart

And $gName came tumbling after. \n";

} else {

//no input yet, create form

print <<<HERE

Please fill in the blanks below, and I'll tell

you a story

<form method = "post"

action = “”>

Boys Name:

<input type = “text”

name = “bName” />

Girls Name

<input type = “text”

name = “gName” />

body part

<input type = “text”

name = “bPart” />

water holding device

bucket cooler glass sip

Tell me the story

HERE;

}

// end if

?>[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service