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
|
<?php
if (isset($_POST['moteur']) AND isset($_POST['host']) AND isset($_POST['text'])) // Si les variables existent
{
if ($_POST['moteur'] != NULL AND $_POST['host'] != NULL AND $_POST['text'] != NULL) // Si on a quelque chose à enregistrer
{
// D'abord, on se connecte à MySQL
mysql_connect("localhost", "root", "");
mysql_select_db("spami");
// On utilise la fonction PHP htmlentities pour éviter d'enregistrer du code HTML dans la table
$moteur = htmlentities ($_POST['moteur']);
$host = htmlentities ($_POST['host']);
$text = htmlentities ($_POST['text']);
// Ensuite on enregistre le message
mysql_query("INSERT INTO edito VALUES('', '$moteur', '$host' '$text')");
// On se déconnecte de MySQL
mysql_close();
}
}
?>
<form method="post" >
<p>
Moteur de recherche : <input type="text" name="moteur" /><br />
Host : <input type="text" name="host" /><br />
Texte : <input type="text" name="text" /><br />
<input type="submit" value="Envoyer" />
</p> |