What's Wrong With This Code? - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › What's Wrong With This Code? (1191 Views)
| What's Wrong With This Code? by ify01(op): 1:06pm On Mar 09, 2017 |
Please can someone figure out the problem with this code? it just keeps displaying errors. <html> <head> <?php $ch1 = " unchecked"; $ch2 = "unchecked"; $ch3 = "unchecked"; $ch4 = "unchecked"; $ch5 = "unchecked"; if (isset($_POST["submit1"])) { if (isset($_POST["ch1"])) { $ch1 = $_POST["ch1"]; if ($ch1 == "word" ![]() {$ch1 = "checked";} } if (isset($_POST["ch2"])) { $ch2 = $_POST["ch2"]; if ($ch2 == "key" ![]() {$ch2 = "checked";} } if (isset($_POST["ch3"])) { $ch3 = $_POST["ch3"]; if ($ch3 == "excel" ![]() {$ch3 = "checked;} } if (isset($_POST["ch4"])) { $ch4 = $_POST["ch4"]; if ($ch4 == "corel" ![]() {$ch4 = "checked";} } if (isset($_POST["ch5"])) { $ch5 = $_POST['ch5']; if ($ch5 == "power" ![]() {$ch5 = "checked";} } } ?> </head> <body> <form name = "form1" method = "post" action = "checkbox.php"> <input type = "Checkbox" name = "ch1" value = "word" <?php print $ch1; ?> >Msword <P> <input type = "Checkbox" name = "ch2" value = "key" <?php print $ch2; ?> >Passkey <P> <input type = "Checkbox" name = "ch3" value = "excel" <?php print $ch3; ?> >Excel <P> <input type = "Checkbox" name = "ch4" value = "corel" <?php print $ch4; ?> >Coreldraw <P> <input type = " Checkbox" name = "ch5" value = "power" <?php print $ch5; ?> >Powerpoint <P> <input type = "submit" name = "submit1" value = "Select your choices"> </form> </body> </html> |
| Re: What's Wrong With This Code? by Donald3d(m): 2:29pm On Mar 09, 2017 |
first of all I had a hard time reading your if statement,use switch next time.My head hurts if you dont want to use switch just use AND/OR to combine all of them In your html the p tag was not closed Also the input tag close it Modified Where you have $ch3="checked....... You missed the second apostrophe. |
| Re: What's Wrong With This Code? by hotwax: 4:31pm On Mar 09, 2017 |
Your braces are killing...Use a better construct like switch...case However, send us the error message, that can help us to help u |
| Re: What's Wrong With This Code? by ify01(op): 6:05pm On Mar 09, 2017 |
Donald3d:Thanks. The error was as a result of the apostrophe. you said something about switch. . . i would appreciate a sample of how I can use switch or AND/OR as per this code. |
| Re: What's Wrong With This Code? by ify01(op): 6:07pm On Mar 09, 2017 |
hotwax:Thanks. I would appreciate if you can give me a sample of using switch . . . |
Please,Help Explain This Code In C • Java Code Pls Modify This Code Help • Java Programmers ,I Need Help Fixing This Code. • 2 • 3 • 4
Tips To Create The Most Amazing Iphone Apps For Your Business • Google Startup Story • Seun Unflag W.A.P.K.A Dot M0BI Domain On Nairaland
