paulmo Posted March 1, 2008 Share Posted March 1, 2008 this form code was executing/printing fine before i started the if/elseif statements near the bottom. getting the whitespace/variable t errors but i'm guessing something else is wrong...need to have if/ifelse statements dependent on the 'theme' selections of a radio field, on the html form. <?php //Check whether the form has been submitted if (array_key_exists('check_submit', $_POST)){ //Converts the new line characters (\n) in the text area into HTML line breaks (the <br /> tag) $_POST['Comments'] = nl2br($_POST['Comments']); //Check whether a $_GET['Languages'] is set if ( isset($_POST['Colors']) ) { $_POST['Colors'] = implode(', ', $_POST['Colors']); //Converts an array into a single string } //Let's now print out the received values in the browser if ($theme == black) { echo "Dark day,($_POST['Name'])"; } elseif ($theme == light) { echo "Lightness prevails,($_POST['Name'])"; }elseif ($theme == grey) { echo "Somber day,($_POST['Name'])"; } else { echo "Please choose a value."; } ?> Quote Link to comment Share on other sites More sharing options...
p2grace Posted March 1, 2008 Share Posted March 1, 2008 First thing I noticed is that you need black light grey in quotes so it can compare it. <?php if ($theme == 'black') { echo "Dark day,($_POST['Name'])"; } elseif ($theme == 'light') { echo "Lightness prevails,($_POST['Name'])"; }elseif ($theme == 'grey') { echo "Somber day,($_POST['Name'])"; } else { echo "Please choose a value."; } ?> Quote Link to comment Share on other sites More sharing options...
paulmo Posted March 1, 2008 Author Share Posted March 1, 2008 thanks but that's still not working (copy/pasted your revision without <?php of course as that tag's at top of complete code. anything else please? Quote Link to comment Share on other sites More sharing options...
p2grace Posted March 1, 2008 Share Posted March 1, 2008 Try this: <?php if ($theme == 'black') { echo "Dark day,(".$_POST['Name'].")"; } elseif ($theme == 'light') { echo "Lightness prevails,(".$_POST['Name'].")"; }elseif ($theme == 'grey') { echo "Somber day,(".$_POST['Name'].")"; } else { echo "Please choose a value."; } ?> Quote Link to comment Share on other sites More sharing options...
paulmo Posted March 2, 2008 Author Share Posted March 2, 2008 copy/pasted again. at least not getting parse/variable t errors now...it's going to the proper page, which is named process.php. the html form is in a separate page; this is the form, whose radio buttons aren't selecting. (they were selecting previously until i deleted some code in the form, and when i got to process.php page the "please choose a value" was printing, which meant that radio selections weren't working anyway, just defaulting): <form action="process.php" method="post"> First Name<input type="text" name="Name"><br> <input type="radio" theme="grey">grey<br> <input type="radio" theme="black">black<br> <input type="radio" theme="light">light<br> <input type="submit" value="Process"> </form> Quote Link to comment Share on other sites More sharing options...
p2grace Posted March 2, 2008 Share Posted March 2, 2008 Hmm without using AJAX here you're best bet off the top of my head to wrap each input in an if statement checking if that input is the one selected. If it is set checked=checked in the input so it's automatically selected. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.