I'm doing something confusing and that should work, but isn't. I'm having an issue getting the value of a hidden input field and being able to see it using PHP. I can't give the actual project, but I'll provide an example.
HTML
<td><input type='hidden' id=emerg_desc value=emerg_desc />emerg_desc</td>
emerg_desc is a javascript variable that dynamically changes when the user interacts with the drag and drop feature. It's what the text is after they drop it. Now, since it's in an input field, I should be able to get the value and pass it to a PHP variable when the user hits submit.
PHP
if($_POST['submit'] == TRUE){
function secure($data){
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return($data);
}
$array = array();
$desc = secure($_POST['emerg_desc']);
array_push($array, $desc);
$arrayLength = count($array);
}
When I call $arrayLength and echo it out, I actually get the correct return value of the array, which is 1. However, when I try to echo the contents of the array, I get nothing. It's like the value is populating the array, but that value is an empty string. Why's this happening?
FOR LOOP FOR THE ARRAY
echo $arrayLength;
for($i = 0; $i < $arrayLength; $i++){
echo $array[$i] .'<br>';
}
I'm even having this problem when I change the input type to text and set the CSS display to none. Sorry I'm not able to show a pen or fiddle of the actual project, it's not something I can legally share.