Ma requete ne fonctionne pas
sebounet25
-
sebounet25 -
sebounet25 -
Bonjour,
Je ne trouve pas mon erreur, j'ai aucun message d'erreur et rien n'est ajouté dans ma base de donnée. Voici le code
J'ai un fonction javascript :
function fct()
{
i = 0;
valid = true;
while (i <= 4)
{
if (frmAjout[i].value == "")
{
valid = false;
}
i = i + 1;
}
if (valid == true)
{
frmAjout.submit();
}
else
{
window.alert("Veuillez compléter les champs obligatoires");
}
}
Voici le code
Et voici la struture de la table projet : NumProjet Nom DateCreat IdentifiantClient Situation
Je ne trouve pas mon erreur, j'ai aucun message d'erreur et rien n'est ajouté dans ma base de donnée. Voici le code
J'ai un fonction javascript :
function fct()
{
i = 0;
valid = true;
while (i <= 4)
{
if (frmAjout[i].value == "")
{
valid = false;
}
i = i + 1;
}
if (valid == true)
{
frmAjout.submit();
}
else
{
window.alert("Veuillez compléter les champs obligatoires");
}
}
Voici le code
<center>Veuillez compléter le formulaire ci dessous afin de créer un nouveau projet (* = champs obligatoire).<br><br>
<form action=projet.php method="POST" name="frmAjout">
<table>
<tr>
<td>
Code du projet *:
</td>
<td>
<input type=text size=20 name=codeprojet value="" >
</td>
</tr>
<tr>
<td>
Nom du projet *:
</td>
<td>
<input type=text size=20 name=nomprojet value="">
</td>
</tr>
<tr>
<td>
Client autorisé *:
</td>
<td>
<input type=text size=20 name=nomclient value="">
</td>
</tr>
<tr>
<td>
Situation *:
</td>
<td>
<SELECT NAME="Situation">
<OPTION VALUE="0" > Veulliez choisir une situation.
<OPTION VALUE="En cours" > En cours
<OPTION VALUE="Terminé" > Terminé
</SELECT>
</td>
</tr>
</table>
<br><input type="button" value="Créer ce projet" onclick="fct();">
<input type="reset" value="Effacer">
<?
mysql_connect("localhost","root","root");
mysql_select_db("Staccato");
if (isset($_POST['codeprojet']) AND isset($_POST['nomprojet']) AND isset($_POST['datecreat']) AND isset($_POST['nomclient']) AND isset($_POST['situation']) )
{
$NumProjet = $_POST['codeprojet'];
$NomProjet = $_POST['nomprojet'];
$DateCreat = date('Y/m/d');
$Client = $_POST['nomclient'];
$situation = $_POST['situation'];
echo "</form>";
$req=mysql_query("SELECT NumProjet FROM Projet WHERE NumProjet = '".$NumProjet."'");
$result = @mysql_result($req, "NumProjet");
if ($result == $NumProjet)
{
echo "Ce projet existe déjà";
}
else
{
// On peut enfin enregistrer :o)
mysql_query("INSERT INTO Projet VALUES('".$NumProjet."', '" .$NomProjet. "','".$DateCreat."', '" .$Client. "', '".$situation."'");
echo "Création du projet effectuée";
echo $NumProjet;
}
}
Et voici la struture de la table projet : NumProjet Nom DateCreat IdentifiantClient Situation
Configuration: Windows Vista Firefox 2.0.0.14