gAhmed gAhmed - 4 months ago 18
HTML Question

Checked html form boxes are NULL

I have a form, but when these things are checked, only Aggregation is posting a 1 as value, the others, even when checked by user are not posting. Entry.php is getting only NULL for these values.

form.html

<form id="submit_entry" action="entry.php" method="post">

<label for=dataFunc>What data functions does this organization/initiative provide? <br></label><br>
<input type="checkbox" name="aggregation" value=1> Aggregation<br>

<input type="checkbox" name="production" value=1> Production<br>

<input type="checkbox" name="analysis" value=1> Analysis<br>

<input type="checkbox" name="advocacy" value=1> Advocacy<br>

<span = "submit><input type="submit"></span>
</form>


entry.php

<?php
$aggregation = $_POST["aggregation"];
$production = $POST_["production"];
$advocacy = $POST_["advocacy"];
$analysis = $POST_["analysis"];
$type = gettype($aggregation);
echo " Aggregation: " . $aggregation . " is data type " . $type . "<br>";
$type = gettype($production);
echo " Production: " . $production . " is data type " . $type . "<br>";
$type = gettype($advocacy);
echo " Advocacy: " . $advocacy . " is data type " . $type . "<br>";
$type = gettype($analysis);
echo " Analysis: " . $analysis . " is data type " . $type . "<br>";
?>


on the form

result from processing post, echoed variable and gettype()

Answer

You have underscores in the wrong places :

                   ▼
$production = $POST_["production"];
$advocacy = $POST_["advocacy"];
$analysis = $POST_["analysis"]; 

Should be :

               ▼
$production = $_POST["production"];
$advocacy = $_POST["advocacy"];
$analysis = $_POST["analysis"]; 
Comments