1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
| <?php
// On commence par récupérer les champs
$question1=isset($_POST["question1"])?$_POST["question1"]:"";
$question2=isset($_POST["question2"])?$_POST["question2"]:"";
$question3=isset($_POST["question3"])?$_POST["question3"]:"";
$question4=isset($_POST["question4"])?$_POST["question4"]:"";
$question5=isset($_POST["question5"])?$_POST["question5"]:"";
$question6=isset($_POST["question6"])?$_POST["question6"]:"";
$question7=isset($_POST["question7"])?$_POST["question7"]:"";
$question8=isset($_POST["question8"])?$_POST["question8"]:"";
$question9=isset($_POST["question9"])?$_POST["question9"]:"";
$question10=isset($_POST["question10"])?$_POST["question10"]:"";
$question11=isset($_POST["question11"])?$_POST["question11"]:"";
$question12=isset($_POST["question12"])?$_POST["question12"]:"";
$question13=isset($_POST["question13"])?$_POST["question13"]:"";
$question14=isset($_POST["question14"])?$_POST["question14"]:"";
$question15=isset($_POST["question15"])?$_POST["question15"]:"";
$question16=isset($_POST["question16"])?$_POST["question16"]:"";
$question17=isset($_POST["question17"])?$_POST["question17"]:"";
$question18=isset($_POST["question18"])?$_POST["question18"]:"";
$question19=isset($_POST["question19"])?$_POST["question19"]:"";
{
// connexion à la base
$db = mysql_connect('localhost', 'root', '') or die('Erreur de connexion '.mysql_error());
// sélection de la base
mysql_select_db('questionnaire',$db) or die('Erreur de selection '.mysql_error());
// on écrit la requête sql
$sql = "INSERT INTO quest (question1, question2, question3, question4, question5, question6, question7, question8,
question9, question10, question11, question12, question13, question14, question15, question16, question17, question18, question19)
VALUES
(
'$question1',
'$question2',
'$question3',
'$question4',
'$question5',
'$question6',
'$question7',
'$question8',
'$question9',
'$question10',
'$question11',
'$question12',
'$question13',
'$question14',
'$question15',
'$question16',
'$question17',
'$question18',
'$question19'
)";
// on insère les informations du formulaire dans la table
mysql_query($sql) or die('Erreur SQL !'.$sql.'<br>'.mysql_error());
}
?> |
Partager