html>
<head>
<title>AJOUT D'UNE DONNÉE</title>
</head>
<body>
<br>
<h2 align=center> AJOUTER UNE DONNÉE</H2>
<BR>
<form method="post" action="page2.php" name="nom_form">
<?
/*----------------------------------------------------------------------
------------------------------------------------------------------------
connection a la base de donnee
-----------------------------------------------------------------------
----------------------------------------------------------------------*/
Include("sql.inc");
mysql_connect($nom_hote, $nom_utilisateur,$password);
$base=mysql_select_db("nom_de_la_base");
if(!$base)
{
echo"connexion impossible";
}
/*----------------------------------------------------------------------
------------------------------------------------------------------------
fin de tentative de connection
-----------------------------------------------------------------------
-----------------------------------------------------------------------
debut du formulaire
-----------------------------------------------------------------------
---------------------------------------------------------------------*/
echo"<table border=0 align=center width=100% CELLSPACING=2>";
echo"<tr>";
echo"<td valign=bottom><p>categorie</td>";
echo"<td >";
echo"<p><form name=\"form1\>";
echo"<select name=\"ligne1\" size=\"1\">";
echo"<select name=\"ligne1\" size=\"1\">";
$table=mysql_query("select * from categorie ");
while($ligne1=mysql_fetch_object($table))
{
echo"<option value=\"$ligne1->categorie\"> $ligne1->categorie </option>";
}
echo"</select>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td valign=bottom><p>titre</td>";
echo"<td ><input type=text name=titre>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td valign=bottom><p>detail</td>";
echo"<td ><input type=text name=detail>";
echo"</td>";
echo"</tr>";
echo"<tr>";
echo"<td height=20></td>";
echo"<td height=20></td>";
echo"</tr>";
echo"<tr>";
echo"<td align=center valign=center><input type=submit name=expedier value=Envoyer></td>";
echo"<td align=center valign=center><input type=reset name=annuler value=Annuler></td>";
echo"</tr>";
echo"</table>";
?>
</form>
</body>
</html>
essaie deja ce code et dis moi ce qu'il en estCode : Tout sélectionner
Include("sql.inc");<?
$nom_hote= "localhost" ;
$nom_utilisateur= "root" ;
$password= "" ;
?>
tout simplement normalement avec ca la premiere page marche$base=mysql_select_db("nom_de_la_base");
if(!$base)
{
echo"connexion impossible";
}
Bien plus simple !mysql_select_db("nom_de_la_base") or die("Connexion impossible");