Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- $db = new PDO('mysql:host=localhost;dbname=questionnaire', 'root', '', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
- }catch(Exception $e){
- echo 'Erreur : '.$e->getMessage().'<br />';
- echo 'NĀ° : '.$e->getCode();
- }
- $question1 = $_POST['question1'];
- $query = $db->prepare("INSERT INTO form (question1 )
- VALUES ('".$question1."')");
- $question1 = isset($_POST['question1']) ? $_POST['question1'] : array();
- foreach($question1 as $reponse1) {
- // here you can use $value
- $query->bindValue('question1', $reponse1, PDO::PARAM_STR);
- }
- $query->execute();
- <div class="col-md-6">
- <label for="question1">
- <input id="question1" type="checkbox" class="form-control" name="question1[]" value="A">
- A
- </label>
- <label for="question1">
- <input id="question1" type="checkbox" class="form-control" name="question1[]" value="B">
- B
- </label>
- <label for="question1">
- <input id="question1" type="checkbox" class="form-control" name="question1[]" value="C">
- C
- </label>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement