Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,156,207 members, 7,829,318 topics. Date: Thursday, 16 May 2024 at 02:01 AM

What's Wrong With This Code? - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / What's Wrong With This Code? (1076 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)

(1) (Reply) (Go Down)

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"wink
{$ch1 = "checked";}
}

if (isset($_POST["ch2"]))
{
$ch2 = $_POST["ch2"];
if ($ch2 == "key"wink
{$ch2 = "checked";}
}
if (isset($_POST["ch3"]))
{
$ch3 = $_POST["ch3"];
if ($ch3 == "excel"wink
{$ch3 = "checked;}
}
if (isset($_POST["ch4"]))
{
$ch4 = $_POST["ch4"];
if ($ch4 == "corel"wink
{$ch4 = "checked";}
}
if (isset($_POST["ch5"]))
{
$ch5 = $_POST['ch5'];
if ($ch5 == "power"wink
{$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:
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.

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:
Your braces are killing...Use a better construct like switch...case

However, send us the error message, that can help us to help u
Thanks. I would appreciate if you can give me a sample of using switch . . .

(1) (Reply)

Meet N - A Nigerian Facebook Messenger Game Chatbot / Come For Your Web Design And Web Development At A Discount Rate / I Am Pitching My Tent On Nairaland! Why You Should Join Me Too.

(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. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.