Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,194,192 members, 7,953,690 topics. Date: Thursday, 19 September 2024 at 11:27 PM |
Nairaland Forum / Science/Technology / Programming / What's Wrong With This Code? (1096 Views)
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)
What's Wrong With This Code? by ify01: 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. 1 Like |
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 1 Like |
Re: What's Wrong With This Code? by ify01: 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: 6:07pm On Mar 09, 2017 |
hotwax:Thanks. I would appreciate if you can give me a sample of using switch . . . |
(1) (Reply)
deleted / A 27-year-old Nigerian App Developer Has Won An Engineering Award / Please Guys Advice Needed Urgently
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 13 |