mercredi 23 octobre 2019

checkbox to php database

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




Aucun commentaire:

Enregistrer un commentaire