yobo Posted November 20, 2009 Share Posted November 20, 2009 Hey All, I was wondering if somone could take a look at this for me? What I am trying to do is change the font colour of the text depending on what the user selected for example I have to pages one page that has the code for the radio buttons the other page that processes it now if the user slects the red radio button i want the next page to output the name of the radio button they selected in that colour so being red. my code is shown below Form Page <?php /** * @author Joe Moore * @copyright 2009 */ ?> <form action="script.php" method="POST"> <input type="radio" name="colours" checked value="red"/> Red<br /> <input type="radio" name="colours" value="blue"/> Blue<br /> <input type="radio" name="colours" value="green"/> Green<br /> <input type="submit" value="GO"/> </form> Process Page (script.php) <?php /** * @author Joe Moore * @copyright 2009 */ echo "<font color="$_POST['colours']"></font>"; ?> all I get is an error phase error msg Link to comment https://forums.phpfreaks.com/topic/182279-unable-to-output-text-depending-on-option/ Share on other sites More sharing options...
rajivgonsalves Posted November 20, 2009 Share Posted November 20, 2009 this echo "<font color="$_POST['colours']"></font>"; should be echo "<font color=".$_POST['colours']."></font>"; Link to comment https://forums.phpfreaks.com/topic/182279-unable-to-output-text-depending-on-option/#findComment-961842 Share on other sites More sharing options...
cags Posted November 20, 2009 Share Posted November 20, 2009 You probably want to use the quotes for the color attribute. echo '<font color="'.$_POST['colours'].'"></font>'; // or echo "<font color=\"{$_POST['colours']}\"></font>"; // etc... Link to comment https://forums.phpfreaks.com/topic/182279-unable-to-output-text-depending-on-option/#findComment-961849 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.