user3453366
user3453366

Reputation: 51

POST Integers PHP AJAX

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?

Upvotes: 0

Views: 276

Answers (1)

jeroen
jeroen

Reputation: 91742

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.

Upvotes: 1

Related Questions