I am an experienced python programmer, however I was aske to make an audit program in php or html. I have no clue what is going on here.. I need help. I created this outline for a program. The program is going to have checkboxes. Depending on what checkboxes are selected, it will output. Ex. if tanks is checked it will print "decommission tanks, and if tanks is not checked it will be blank. How do I do this?!?! also is there anything wrong with this code so far? Like I said I know nothing! and all advice would be great

<html>
<head>
<title>SPARTA Proctor Tool 1.0</title>
</head>
<body>
<b>SPARTA Proctor Tool 1.0 </b> <br>
Created By: Rooking & Wandmdave
</body>

</html>

<form>
<br>

<form action="What does this thing do?">

Nation Name:
<input type="text" name="firstname">
<br>
Nation Ruler:
<input type="text" name="lastname">
<br>
Nation Link:
<input type="text" name="firstname">
<br>
</form>

<html>
<head>
<script type="text/javascript">
function tank()
{
document.write('Decom Tanks');
}
</script>
</head>
<body>
<form>
No more than one empty trade?:
<input type="checkbox" name="trade" onclick="trade()">
<br>
Bonus resources?:
<input type="checkbox" name="checkbox" onclick="checkbox()">
<br>
More than 15 tech?:
<input type="checkbox" name="tech" onclick="tech()">
<br>
Tech to infra ratio better than 5:1:
<input type="checkbox" name="ratio" onclick="ratio()">
<br>
More than 20% soldier pop:
<input type="checkbox" name="soldier" onclick="soldier()">
<br>
Less than 60% soldier pop:
<input type="checkbox" name="soldierpop" onclick="soldierpop()">
<br>
Defcon 5 (unless in times of war):
<input type="checkbox" name="defcon" onclick="defcon()">
<br>
Not in peace mode?:
<input type="checkbox" name="peace" onclick="peace()">
<br>
Government no Comm, dic, or trad?:
<input type="checkbox" name="govt" onclick="govt()">
<br>
Tanks?:
<input type="checkbox" name="tank" onclick="tank()">
<br>
Cruise Missles?:
<input type="checkbox" name="cm" onclick="cm">
</form>
</body>
</html>

<input type="button" value="Audit">
<input type="reset" value="Reset"
<br>

<body>
<br>
© Rooking
</body>

Recommended Answers

All 2 Replies

Like I have the checkbox. I just don't know how to output based on if checked or not. And how to organize it

Instead of having separate names for checkbox, use checkbox array and assign different values to it. When you click on the submit button, only those checkboxes which were checked would be posted. You can then use a foreach loop to get what was checked.

print_r($_POST['checkboxname']) //will print the array of checkboxes checked.

The problem with naming them individually is, for every checkbox, you have to check if it is set and if it has a value !
ie.,

if(isset($_POST['tank'])) {
 //statements
}
if(isset($_POST['defcon'])) {
 //statements
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.