0

Here is what I have so far:

Age: <input type="text" name="age">

   Canoe<input type="radio" name="ck">
        Kayak<input type="radio" name="ck">


<input type="submit" style=" margin-bottom: 30px;">
</form>

You are <?php $_POST["age"];
 if ($_POST["age"]<"11")
 echo "an Atom.";

 elseif ($_POST["age"]<"13")
 echo "a Peewee.";

 elseif ($_POST["age"]<"15")
 echo "a Bantam.";

 elseif ($_POST["age"]<"17")
 echo  "a Midget.";

 elseif ($_POST["age"]<"19")
 echo "a Juvenile.";

 elseif ($_POST["age"]<"21")
 echo "a Junior.";

 elseif ($_POST["age"]<"120")
 echo "a Senior.";

 elseif ($_POST["age"]>"120")
 echo "too old to race";
   ?>   

I want to be able to include the canoe and kayak radio buttons in this to make the output be like: You are a Peewee canoeist and your opponents this year are: | or, you are a midget kayak er. You're opponents this year are:

2 Answers 2

1

Are you trying to echo the CK value into your output? Does this help?

Age: <input type="text" name="age">

Canoe<input type="radio" name="ck" value="canoeist">
Kayak<input type="radio" name="ck" value="kayakist">

<input type="submit" style=" margin-bottom: 30px;">
</form>

<?php
        $ck = $_POST["ck"];
?>

You are <?php $_POST["age"];
if ($_POST["age"]<"11")
echo "a $ck Atom.";

elseif ($_POST["age"]<"13")
echo "a $ck Peewee.";

elseif ($_POST["age"]<"15")
echo "a $ck Bantam.";

elseif ($_POST["age"]<"17")
echo  "a $ck Midget.";

elseif ($_POST["age"]<"19")
echo "a $ck Juvenile.";

elseif ($_POST["age"]<"21")
echo "a $ck Junior.";

elseif ($_POST["age"]<"120")
echo "a $ck Senior.";

elseif ($_POST["age"]>"120")
echo "too old to race";
?>

The values of the form radio must be canoeist and "kayakist". Just add the $ck = $_POST['ck']; and your sentence is like echo "a $ck Atom.";

Sign up to request clarification or add additional context in comments.

1 Comment

nice straightforward solution
0

You should use some variables here.

(I'm not that good at php, but I'll give it a try)

Age: <input type="text" name="age">

    Canoe<input type="radio" name="ck" value="canoe"/>
    Kayak<input type="radio" name="ck" value="kayak"/>

<input type="submit" style=" margin-bottom: 30px;">
</form>

$boat = "";
if ($_POST["ck"] == "canoe")
{
    $boat = "canoeist";
} else if ($_POST["ck"] == "kayak")
{
    $boat = "kayak er";
}


$rank = "";
You are <?php $_POST["age"];
 if ($_POST["age"]<"11")
 $rank = "an Atom.";

 elseif ($_POST["age"]<"13")
 $rank = "a Peewee.";

 elseif ($_POST["age"]<"15")
 $rank = "a Bantam.";

 elseif ($_POST["age"]<"17")
 $rank =  "a Midget.";

 elseif ($_POST["age"]<"19")
 $rank = "a Juvenile.";

 elseif ($_POST["age"]<"21")
 $rank = "a Junior.";

 elseif ($_POST["age"]<"120")
 $rank = "a Senior.";

 elseif ($_POST["age"]>"120")
 $rank = "too old to race";

 echo "You are " . $rank . " " . $boat;
   ?>   

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.