strategos Posted March 28, 2012 Share Posted March 28, 2012 Hi, I'm new to PHP and testing a simple script. However, it won't change to red when I input the red radio button. Would anyone happen to know why? <?php $check = $_POST['check']; $submit = $_POST['S1']; if ($check = "1") { $color = "green"; } elseif ($check = "2") { $color = "red"; } var_dump($check); ?> <html> <body> <h1 style="color:<?php echo $color; ?>;">The h1 is <?php echo $color; ?>!</h1> <form method="POST" action="test.php"> <input type="radio" value="1" name="check" /> Green <br /> <input type="radio" value="2" name="check" /> Red <br /><br /> <input type="submit" name="S1" value="submit" /> </form> </body> </html> Quote Link to comment https://forums.phpfreaks.com/topic/259893-lua-learner-help/ Share on other sites More sharing options...
trq Posted March 28, 2012 Share Posted March 28, 2012 == is the comparison operator in PHP, not = Quote Link to comment https://forums.phpfreaks.com/topic/259893-lua-learner-help/#findComment-1332063 Share on other sites More sharing options...
strategos Posted March 28, 2012 Author Share Posted March 28, 2012 Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/259893-lua-learner-help/#findComment-1332117 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.