Erreure PHP

Résolu/Fermé
Super_carotte Messages postés 1419 Date d'inscription mardi 8 janvier 2008 Statut Membre Dernière intervention 27 janvier 2015 - 9 janv. 2008 à 06:27
Super_carotte Messages postés 1419 Date d'inscription mardi 8 janvier 2008 Statut Membre Dernière intervention 27 janvier 2015 - 9 janv. 2008 à 10:36
Bonjour a vous,
En utilisant le code suivant je reçoit ce message d'erreure: Pourriez vous me dire d'ou vien mon probleme SVP?

Notice: Undefined variable: nom in C:\Program Files\EasyPHP 2.0b1\www\AJR\formulaireInscription.php on line 20
// cette ligne est normal c'est mon message d'erreure quand un des champs n'est pas remplis.
Attention touts les champs avec une "*" doivent etre remplis ![Retour]

CODE PHP:
<?php
//*************************************************
//*************************************************
// AJR
// Creation d'un nouvel utilisateur
//*************************************************

// Insertion d un utilisateur ds la BD
//*************************************************

// Inclusion et execution du fichier db.php
require('db.php');
$_SESSION["StatutErreur"] = '';



// Test qur le bouton clique
if($_POST["ValiderInscription"]=='Valider') // Si bouton de validation

if(empty($_POST[$nom]) OR empty($_POST[$prenom]) OR empty($_POST[$ville]) OR empty($_POST[$codepostal]) OR empty($_POST[$addresse]) OR empty($_POST[$email]) OR empty($_POST[$tel1]) OR empty($_POST[$type]))
{
echo 'Attention touts les champs avec une "*" doivent etre remplis !';


// Insertion du lien de retour
//=========================================
echo '<a href="formulaireinscription.htm" title="S\'inscrire dans l\'espace">[Retour]</a><br>';

}
// Aucun champ n'est vide, on peut enregistrer dans la table
else



{
// Recuperation des valeurs contenues dans les champs de saisie
$nom = htmlspecialchars(addslashes($_POST["nom"] ));
$prenom = htmlspecialchars(addslashes($_POST["prenom"] ));
$ville = htmlspecialchars(addslashes($_POST["ville"] ));
$codepostal = htmlspecialchars(addslashes($_POST["codepostal"] ));
$addresse = htmlspecialchars(addslashes($_POST["addresse"] ));
$email = htmlspecialchars(addslashes($_POST["email"] ));
$tel1 = htmlspecialchars(addslashes($_POST["tel1"] ));
$tel2 = htmlspecialchars(addslashes($_POST["tel2"] ));
$idparain = htmlspecialchars(addslashes($_POST["idparain"] ));
$nomparain = htmlspecialchars(addslashes($_POST["nomparain"] ));
$prenomparain = htmlspecialchars(addslashes($_POST["prenomparain"] ));
$type = htmlspecialchars(addslashes($_POST["type"] ));


echo "<br>nom = ".$nom;
// Insertion de l utilisateur dans la BD User
mysql_query("Insert Into adherent (nom,prenom,ville,codepostal,addresse,email,tel1,tel2,idparain,nomparain,prenomparain,type) VALUES ('$nom','$prenom','$ville','$codepostal','$addresse','$email','$tel1','$tel2','$idparain','$nomparain','$prenomparain','$type')") or die ("Erreur insert: ".mysql_error());




// Insertion du lien de retour
//=========================================
echo '<a href="index.php" title="S\'inscrire dans l\'espace">[Retour]</a><br>';
// Fermeture de la connexion MySQL
@mysql_close();
header('location: index.php');
}

HTML:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link rel="STYLESHEET" type="text/css" href="styles.css">
<title>Inscription d'un nouveau membre</title>
</head>
<body>
<div align="center">
<h2>Inscription d'un nouveau membre </h2>

<a>Vous souhaitez créer un compte</a><br>
<a>Pour cela, remplissez les champs suivants :</a><br>
<a>Attention les champs suivis d'une "*" doivent etre imperativement remplis!</a>
<br>

<form action="http://localhost/AJR/formulaireinscription.php" method="post" name="formulaireinscription.htm">

<table>
<tr>
<td>Nom:*</td>
<td><input type="text" name="nom"></td>
</tr>
<tr>
<td>Prenom*</td>
<td><input type="text" name="prenom"></td>
</tr>
<tr>
<td>Ville:*</td>
<td><input type="text" name="ville"></td>
</tr>
<tr>
<td>Code postal:*</td>
<td><input type="text" name="codepostal"></td>
</tr>
<tr>
<td>Adresse:*</td>
<td><input type="text" name="addresse"></td>
</tr>
<tr>
<td>email:*</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td>Tel1:*</td>
<td><input type="text" name="tel1"></td>
</tr>
<tr>
<td>Tel2:</td>
<td><input type="text" name="tel2"></td>
</tr>
<tr>
<td>ID parain:</td>
<td><input type="text" name="idparain"></td>
</tr>
<tr>
<td>Nom parain:</td>
<td><input type="text" name="nomparain"></td>
</tr>
<tr>
<td>Prenom parain:</td>
<td><input type="text" name="prenomparain"></td>
</tr>
<tr>
<td> Type:*</td>
<td>
<select NAME="type">
<option VALUE="membre">Membre
<option VALUE="Membreactif">Membre actif
<option VALUE="membrebureau">Membre du bureau
<option VALUE="membrebureau">Membre du conseil d'administration
<option VALUE="Autre">Autre
</select>
</td>
</tr>

</table>

<br><br>

<input type="submit" name="ValiderInscription" value="Valider">
<input type="reset" name="AnnulerInscription" value="Annuler">

</form>

</div>
<a href="index.php" title="S\'inscrire dans l\'espace">[Retour a l index]</a><br>
</body>
A voir également:

2 réponses

bibi675 Messages postés 387 Date d'inscription mardi 1 janvier 2008 Statut Membre Dernière intervention 30 décembre 2008 20
9 janv. 2008 à 09:38
empty($_POST[$tavariable]) >> Il faut déclarer la variable avant de la vérifier...
0
Super_carotte Messages postés 1419 Date d'inscription mardi 8 janvier 2008 Statut Membre Dernière intervention 27 janvier 2015 127
9 janv. 2008 à 10:36
merci
0