Reputation: 75
This is my checkbox
<input name="interests2" type="checkbox" value="double-deep-racks" />
This is how I am trying to get that value in to a variable
$int = $_POST['interests2'];
Can you please tell me what i am doing wrong. I cant get the values I just get blank.
Upvotes: 1
Views: 7135
Reputation: 2967
Try
$int = $_POST['interests2'];
If you are trying to set multiple checkboxes you can do something like,
// Your html
<input type="checkbox" name="interests[]" value="This is i">
<input type="checkbox" name="interests[]" value="Another i value">
// php
$email = "Further Information In: \n";
foreach($_POST['interests'] as $i)
$email .= $i . "\n";
Upvotes: 3
Reputation: 32532
The name
element must match what you are looking for. In your input field the name is interests2
but you are looking for interests
(missing "2").
Also, you may possibly need to look in $_GET
instead of $_POST
, depending on the form or the AJAX method you are using (you didn't post that portion of your code).
Upvotes: 0
Reputation: 3302
The name of your checkbox is interests2
. You must get the value by that name like this:
$int = $_POST['interests2'];
Upvotes: 2