Hi I am working on an assignment to input 3 checked items into my database. I can't use arrays for this.
Here is my form:
<p>What are your categories of interest? (Select as many as you'd
like below)</p>
<input name="industry" type="checkbox" value="industry"
/>Industry<br />
<input name="technical" type="checkbox" value="technical"
/>Technical<br />
<input name="career" type="checkbox" value="career" />Career<br />
Here is my php:
$name = $_POST["name"];
$email = $_POST["email"];
$industry = $_POST["industry"];
$technical = $_POST["technical"];
$career = $_POST["career"];
$role = $_POST["role"];
include("includes/dbconfig.php");
$stmt = $pdo->prepare("INSERT INTO `contacts` (`contactid`, `name`,
`email`, `industry`, `technical`, `career` `role`) VALUES (NULL,
'$name', '$email', '$industry', '$technical', '$career',
'$role');");
$stmt->execute();
header("location:contactthankyou.php");
?>
and my database table has 3 columns (industry, technical, career).
NOTHING WORKS please help
I tried this:
if(! isset($_POST["industry"]))
{$industry = "notchecked";
}else{
$industry = $_POST["industry"];}
It did not work...
And this:
$industry = false;
if( isset($_POST["industry"]))
{
$industry = true;
}
What are your categories of interest? (Select as many as you'd like below) .
IndustryTechnical
Career
– P Smith Oct 23 '19 at 20:20