Question

I am using a POST method with AJAX to send an integer value from a form to the php script to be inserted into a database. When I do this the value is always zero when I cast it e.g $int = (int)$_POST['total']; and $int = intval($_POST['total']); and when I do not cast it the $int variable is assigned a string, when I var_dump the $_POST i get array(1) { ["int"]=> string(2) "20" } returned to the screen. does anybody know how to help me?

Was it helpful?

Solution

It would seem your variable is located in $_POST['int'] and not in $_POST['total']. So change the name attribute or the php to correct that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top