Hello everyone , i just need to insert into my database the state of 4 checkbox , i'm trying now only for two . For this, i have two file formulaire.html and form.php , I've created for each checkbox a column in my database , so , what i want to get finaly is to know the state of each checkbox , if its checked in checkbox1 column i want find "yes" or "1" , if it's not checked "no" or "0" , and the same for all checkboxs .
this is the code for the form in html :
<form style="height: 943px;" method="post" action="form11111.php" name="monformulaire"><br>
<label style="position: absolute; z-index: 10; top: 73px; left: 50px;">Nom
:</label> <input size="10" name="Nom" style="position: absolute; z-index: 10; top: 70px; left: 170px;">
<input size="10" name="Prenom" style="position: absolute; z-index: 10; top: 70px; left: 417px;"><label style="position: absolute; z-index: 10; top: 73px; left: 330px;">Prénom
:</label>
<input size="10" name="Fonction" style="position: absolute; z-index: 10; top: 110px; left: 417px;"><label style="position: absolute; z-index: 10; top: 113px; left: 330px;">Fonction
:</label>
<input size="10" name="Datedemande" style="position: absolute; z-index: 10; top: 70px; left: 783px;"><label style="position: absolute; z-index: 10; top: 73px; left: 610px;"> Date
de la demande :</label> <label style="position: absolute; z-index: 10; top: 113px; left: 50px;">Département
:</label>
<input size="10" name="Departement" style="position: absolute; z-index: 10; top: 110px; left: 170px;">
<label style="position: absolute; z-index: 10; top: 603px; left: 50px;">Téléphone :</label>
<input size="10" name="phone" style="position: absolute; z-index: 10; top: 600px; left: 160px;">
<label style="position: absolute; z-index: 10; top: 603px; left: 370px;">N1</label>
<label style="position: absolute; z-index: 10; top: 603px; left: 470px;">N2</label>
<input type="checkbox" name="boxes[]" value="" style="position: absolute; z-index: 10; top: 603px; left: 550px;" ></input>
<input type="checkbox" name="boxes[]" value="" style="position: absolute; z-index: 10; top: 603px; left: 450px;" ></input>
<input value="Envoyer" style="position: absolute; z-index: 10; top: 603px; left: 750px;" type="submit"><br>
</form>
And this is the code of php , with test in printings the state of checkboxs in the php web page form11111.php :
<!DOCTYPE html>
<html>
<head><title>Example</title></head>
<body>
test checkbox
<pre>
<?php
$db = mysql_connect('localhost', 'root', 'mysql');
mysql_select_db('InfoPerso',$db);
// Recuperation des valeurs :
$Nom = $_POST['Nom'];
$Departement = $_POST['Departement'];
$Prenom = $_POST['Prenom'];
$Fonction = $_POST['Fonction'];
$Datedemande = $_POST['Datedemande'];
$phone = $_POST['phone'];
$_boxValue = $_POST['boxes'];
if(isset($_POST['boxes']))
{
foreach ($_POST['boxes'] as $_boxValue)
{
echo "Box #{$_POST['boxes']} was selected!\n";
}
}
echo "Box #{$phone} was selected!\n";
// Insertion des valeurs :
$insertion = "INSERT into Personnes (Nompersonne, NomDep, Prenompersonne, Fonction, DateDemande, Telephone, N1 ) values
('$Nom', '$Departement','$Prenom','$Fonction','$Datedemande','$phone','$_boxValue')";
mysql_query($insertion) or die ('Error : '. mysql_error());
?>
</pre>
</body>
</html>
Thank you very much for your answers .