Radio Buttons Font Changing Help Please!

So, I’m sitting here with my friend Eliza who is taking a PHP programming class. I have no experience myself with radio buttons, but we need to create a script to accomplish this: http://yorktown.cbe.wwu.edu/sandvig/mis314/Assignments/A03/FontPicker.php

Here is the actual assignment. We figured out everything else except part 6:
https://yorktown.cbe.wwu.edu/sandvig/mis314/assignments/Assignment03.aspx

Here is what we have so far, which isn’t much:

[php]

<?php $message = $_GET['message']; if(empty($message)) $message = "The Quick Brown Fox Jumps Over the Lazy Dog"; ?> Funky Font Message

Funky Font Message


Please select a font and enter a message:

Chunk Red Deco Blue Animals Elegant Red Funky TapePunch

<?php $ChunkRed=$_POST['ChunkRed']; $DecoBlue=$_POST['DecoBlue']; $Animals=$_POST['Animals']; $ElegantRed=$_POST['ElegantRed']; $Funky=$_POST['Funky']; $TapePunch=$_POST['TapePunch']; //parse individual characters from $message and display character image for($i = 0; $i < strlen($font); ++$i) $char = substr($font, $i, 1); // display
tags for spaces if ($char != " ") { echo"\n"; //else { //echo "
\n"; // } ?> [/php]

Any help would be greatly appreciated, as the assignment is due tomorrow. We definitely want to know how to do it, not just get the answer. Thanks!!!

We have this much now:

[php]

<?php $message = $_GET['message']; if(empty($message)) $message = "The Quick Brown Fox Jumps Over the Lazy Dog"; ?> Funky Font Message

Funky Font Message


Please select a font and enter a message:

Chunk Red Deco Blue Animals Elegant Red Funky TapePunch

<?php $ChunkRed=$_POST['ChunkRed']; $DecoBlue=$_POST['DecoBlue']; $Animals=$_POST['Animals']; $ElegantRed=$_POST['ElegantRed']; $Funky=$_POST['Funky']; $TapePunch=$_POST['TapePunch']; //parse individual characters from $message and display character image for($i = 0; $i < strlen($message); ++$i) { $char = substr($message, $i, 1); // display
tags for spaces if ($_POST == $ChunkRed) { echo "\n"; } elseif ($_POST == $DecoBlue) { echo "\n"; } elseif ($_POST == $Animals) { echo "\n"; } elseif ($_POST == $ElegantRed) { echo "\n"; } elseif ($_POST == $Funky) { echo "\n"; } elseif ($_POST == $TapePunch) { echo "\n"; } else { echo "Bite me
\n"; } } ?> [/php]

You are using the POST variables incorrectly.

[php]$ChunkRed=$_POST[‘ChunkRed’];[/php]

This wouldn’t be valid since you are looking for the value instead of the key name. Your radio name is “font” so that is the key that you access in your $_POST array.

So to check a font you would need to do:

[php]if ($_POST[‘font’] == ‘ChunkRed’)[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service