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
| <br/>
<form action="index.php?p=1&a=2" method="POST">
<label title="titre">Titre</label>
<input type="text" name="titre" /><br/>
<label title="cat">Catgorie</label>
<select name="cat">
<option value="1">Choix 1</option>
<option value="2">Choix 2</option>
<option value="3">Choix 3</option>
</select><br/>
<p>Contenu de la news</p>
<textarea name="contenu" rows="8" cols="45"></textarea>
<br/><input name="Envoyer" type="submit" value="Publier"/>
</form>
<?php
}
elseif ($p == 1 && $a == 2)
{
$_POST['cat'] = $cat;
$_POST['titre'] = $titre;
$contenu = nl2br(addslashes($_POST['contenu']));
if (empty($cat) || empty($titre) || empty($contenu))
{
echo '<br/>Vous avez oublié un champs.<br/>
News publié: <span style="color: red;"><b>[ERREUR]</b></span>';
}
else
{
$req1 = mysql_query("INSERT INTO news VALUES('', '$cat', '$titre', '$contenu' )") or die(mysql_error());
echo 'News publié: <span style="color: green;"><b>[OK]</b></span>';
}
} |
Partager