Problème en code inscrire et vérifier client
bobch
Messages postés
14
Statut
Membre
-
bobch Messages postés 14 Statut Membre -
bobch Messages postés 14 Statut Membre -
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>Sve </title>
<script type="text/javascript" src="script.js"></script>
<style type="text/css">
<!--
body {
background-image: url(WWWnew.jpg);
background-repeat: no-repeat;
body {background-color: #FF0000;}
-->
</style></head>
<body>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<li>
<a href="acceuil.php" class=" active"><span class="l"></span><span class="r"></span><span class="t">Acceuil</span></a>
</li>
<li><a href="page.html" class=" active"><span class="l"></span><span class="r"></span><span class="t">Visite</span></a>
</li>
<h1 id="name-text" class="art-Logo-name"> </h1>
<h1 class="art-Logo-name"><a href="#">DevSve</a></h1>
<br />
<div id="slogan-text" class="art-Logo-text">Vous aimez bien le shopping mais vous avez des responsabilités alors DevSve vous ouvre la portails du net shopping à tous moment <br /> Nous sommes là toujours pour vous rendre la vie plus confort <br /> </div>
</div>
</div>
<div class="art-content">
<div class="art-Post">
<?php
include('connex_base.php');
if (isset ($_POST["modif"]))
{
$email=$_POST['email'];
$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$tel=$_POST["tel"];
$login=$_POST['login'];
$pwd=$_POST['pwd'];
$adr=$_POST['adr'];
$numcarteB=$_POST['numcarteB'];
$codecarteB=$_POST['codecarteB'];
$sql="insert into 'sve_client' (
'id_client' ,
'nom_client' ,
'prenom_client' ,
'tel_client' ,
'email_client' ,
'login_client' ,
'pwd_client' ,
'adr_client' ,
'numcarteB_client' ,
'codecarteB_client'
)
VALUES (
NULL , '$nom', '$prenom', '$tel', '$email', '$login', '$pwd', '$adr', '$numcarteB', '$codecarteB');";
$req=mysql_query($sql)
or die("erreur sql ".mysql_error());
echo "inscription reussie";
}
if(!taille_variable('login',4,10)){
echo'Login invalide, rentrez minimum 4 caractères';
echo'<br>';
}elseif (!taille_variable('pwd',5,15)){
echo'Mot de passe invalide, rentrez minimum 5 caractères, 40 caractères maximum';
echo'<br>';
}elseif (!taille_variable('email',10,15)){
echo'email invalide, rentrez minimum 10 caractères';
echo'<br>';
}
if (!strpos($_POST['email'],'@')){
echo'Adresse mail non valide';
}
list($localhost,$dns)=explode("@",$_POST['email']);
If (!checkdnsrr($dns)){
echo'L\'adresse mail n\'est pas valide';
}
if(!taille_variable('nom',5,20)){
echo'Nom invalide, rentrez votre nom (minimum 5 lettres)';
echo'<br>';
}
elseif (!taille_variable('prenom',5,20)){
echo'Prenom invalide, rentrez votre prenom';
echo'<br>';
}
if (strlen($_POST["tel"])<>0){
if(!taille_variable('tel',6,10)){
echo'Numéro de téléphone non valide';
echo'<br>';
}
}
if (!taille_variable('adr',15,25)){
echo' adresse invalide, rentrez minimum 15 caractères';
echo'<br>';
}
if (!taille_variable('numcarteB',10,15)){
echo' numero compte invalide, rentrez minimum 15 caractères';
echo'<br>';
}
if (!taille_variable('codecarteB',4,8)){
echo' code invalide, rentrez minimum 4 caractères';
echo'<br>';
}
?>
<br />
<br />
<center>
<p> </p>
<h2> </h2>
<h2>Nouveau client</h2>
</tt>
</center>
<center>
<form action="inscri.php" method="post">
<table width="74%" cellpadding="5" cellspacing="0" class="mod-form" style="margin: 10px 0; border: 0;">
<tr>
<td width="20%">Email</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="email" name="email"></td>
</tr>
<tr>
<td width="20%">Nom</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="nom" name="nom" /></td>
</tr>
<tr>
<td width="20%">Prenom</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="prenom" name="prenom"></td>
</tr>
<tr>
<td width="20%">Téléphone</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="tel" name="tel"></td>
</tr>
<tr>
<td width="20%">Login</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="login" name="login" /></td>
</tr>
<tr>
<td width="20%">Password</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="pwd" name="pwd"></td>
</tr>
<tr>
<td width="20%">Adresse</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="adr" name="adr"></td>
</tr>
<tr>
<td width="20%">Numero Carte Bancaire</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="numcarteB" name="numcarteB"></td>
</tr>
<tr>
<td width="20%">Code Carte Bancaire</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="codecarteB" name="codecarteB"></td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $tableau['id_client'] ; ?>">
<input type="submit" name="modif" class="mod-form-button" value="Valider">
<input name="reset" type='reset' value='Annuler' />
</p>
</form>
</center>
<?php
function taille_variable($variable,$taille_min=0,$taille_max=0){
global $_POST;
if(!isset($_POST[$variable])){
// valeur non définie
return false;
}elseif (strlen($_POST[$variable])<$taille_min){
return False;
}elseif(strlen($_POST[$variable])>$taille_max){
return FALSE;
}
return True;
}
?>
</div> </div> <div class="cleared"></div>
</body>
</html>
mais voilà le message d'erreur aidez moi svp :
Notice: Undefined index: email in C:\Program Files\EasyPHP-5.3.2i\www\sve\insc_client_verf.php on line 96
Adresse mail non valide
Notice: Undefined index: email in C:\Program Files\EasyPHP-5.3.2i\www\sve\insc_client_verf.php on line 99
Notice: Undefined offset: 1 in C:\Program Files\EasyPHP-5.3.2i\www\sve\insc_client_verf.php on line 99
L'adresse mail n'est pas valideNom invalide, rentrez votre nom (minimum 5 lettres)
Notice: Undefined index: tel in C:\Program Files\EasyPHP-5.3.2i\www\sve\insc_client_verf.php on line 112
adresse invalide, rentrez minimum 15 caractères
numero compte invalide, rentrez minimum 15 caractères
code invalide, rentrez minimum 4 caractères
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>Sve </title>
<script type="text/javascript" src="script.js"></script>
<style type="text/css">
<!--
body {
background-image: url(WWWnew.jpg);
background-repeat: no-repeat;
body {background-color: #FF0000;}
-->
</style></head>
<body>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<li>
<a href="acceuil.php" class=" active"><span class="l"></span><span class="r"></span><span class="t">Acceuil</span></a>
</li>
<li><a href="page.html" class=" active"><span class="l"></span><span class="r"></span><span class="t">Visite</span></a>
</li>
<h1 id="name-text" class="art-Logo-name"> </h1>
<h1 class="art-Logo-name"><a href="#">DevSve</a></h1>
<br />
<div id="slogan-text" class="art-Logo-text">Vous aimez bien le shopping mais vous avez des responsabilités alors DevSve vous ouvre la portails du net shopping à tous moment <br /> Nous sommes là toujours pour vous rendre la vie plus confort <br /> </div>
</div>
</div>
<div class="art-content">
<div class="art-Post">
<?php
include('connex_base.php');
if (isset ($_POST["modif"]))
{
$email=$_POST['email'];
$nom=$_POST['nom'];
$prenom=$_POST['prenom'];
$tel=$_POST["tel"];
$login=$_POST['login'];
$pwd=$_POST['pwd'];
$adr=$_POST['adr'];
$numcarteB=$_POST['numcarteB'];
$codecarteB=$_POST['codecarteB'];
$sql="insert into 'sve_client' (
'id_client' ,
'nom_client' ,
'prenom_client' ,
'tel_client' ,
'email_client' ,
'login_client' ,
'pwd_client' ,
'adr_client' ,
'numcarteB_client' ,
'codecarteB_client'
)
VALUES (
NULL , '$nom', '$prenom', '$tel', '$email', '$login', '$pwd', '$adr', '$numcarteB', '$codecarteB');";
$req=mysql_query($sql)
or die("erreur sql ".mysql_error());
echo "inscription reussie";
}
if(!taille_variable('login',4,10)){
echo'Login invalide, rentrez minimum 4 caractères';
echo'<br>';
}elseif (!taille_variable('pwd',5,15)){
echo'Mot de passe invalide, rentrez minimum 5 caractères, 40 caractères maximum';
echo'<br>';
}elseif (!taille_variable('email',10,15)){
echo'email invalide, rentrez minimum 10 caractères';
echo'<br>';
}
if (!strpos($_POST['email'],'@')){
echo'Adresse mail non valide';
}
list($localhost,$dns)=explode("@",$_POST['email']);
If (!checkdnsrr($dns)){
echo'L\'adresse mail n\'est pas valide';
}
if(!taille_variable('nom',5,20)){
echo'Nom invalide, rentrez votre nom (minimum 5 lettres)';
echo'<br>';
}
elseif (!taille_variable('prenom',5,20)){
echo'Prenom invalide, rentrez votre prenom';
echo'<br>';
}
if (strlen($_POST["tel"])<>0){
if(!taille_variable('tel',6,10)){
echo'Numéro de téléphone non valide';
echo'<br>';
}
}
if (!taille_variable('adr',15,25)){
echo' adresse invalide, rentrez minimum 15 caractères';
echo'<br>';
}
if (!taille_variable('numcarteB',10,15)){
echo' numero compte invalide, rentrez minimum 15 caractères';
echo'<br>';
}
if (!taille_variable('codecarteB',4,8)){
echo' code invalide, rentrez minimum 4 caractères';
echo'<br>';
}
?>
<br />
<br />
<center>
<p> </p>
<h2> </h2>
<h2>Nouveau client</h2>
</tt>
</center>
<center>
<form action="inscri.php" method="post">
<table width="74%" cellpadding="5" cellspacing="0" class="mod-form" style="margin: 10px 0; border: 0;">
<tr>
<td width="20%">Email</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="email" name="email"></td>
</tr>
<tr>
<td width="20%">Nom</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="nom" name="nom" /></td>
</tr>
<tr>
<td width="20%">Prenom</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="prenom" name="prenom"></td>
</tr>
<tr>
<td width="20%">Téléphone</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="tel" name="tel"></td>
</tr>
<tr>
<td width="20%">Login</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="login" name="login" /></td>
</tr>
<tr>
<td width="20%">Password</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="pwd" name="pwd"></td>
</tr>
<tr>
<td width="20%">Adresse</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="adr" name="adr"></td>
</tr>
<tr>
<td width="20%">Numero Carte Bancaire</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="numcarteB" name="numcarteB"></td>
</tr>
<tr>
<td width="20%">Code Carte Bancaire</td>
<td width="80%"><input class="mod-input" style="width:100%;" maxlength="255" id="codecarteB" name="codecarteB"></td>
</tr>
</table>
<input type="hidden" name="id" value="<?php echo $tableau['id_client'] ; ?>">
<input type="submit" name="modif" class="mod-form-button" value="Valider">
<input name="reset" type='reset' value='Annuler' />
</p>
</form>
</center>
<?php
function taille_variable($variable,$taille_min=0,$taille_max=0){
global $_POST;
if(!isset($_POST[$variable])){
// valeur non définie
return false;
}elseif (strlen($_POST[$variable])<$taille_min){
return False;
}elseif(strlen($_POST[$variable])>$taille_max){
return FALSE;
}
return True;
}
?>
</div> </div> <div class="cleared"></div>
</body>
</html>
mais voilà le message d'erreur aidez moi svp :
Notice: Undefined index: email in C:\Program Files\EasyPHP-5.3.2i\www\sve\insc_client_verf.php on line 96
Adresse mail non valide
Notice: Undefined index: email in C:\Program Files\EasyPHP-5.3.2i\www\sve\insc_client_verf.php on line 99
Notice: Undefined offset: 1 in C:\Program Files\EasyPHP-5.3.2i\www\sve\insc_client_verf.php on line 99
L'adresse mail n'est pas valideNom invalide, rentrez votre nom (minimum 5 lettres)
Notice: Undefined index: tel in C:\Program Files\EasyPHP-5.3.2i\www\sve\insc_client_verf.php on line 112
adresse invalide, rentrez minimum 15 caractères
numero compte invalide, rentrez minimum 15 caractères
code invalide, rentrez minimum 4 caractères
A voir également:
- Problème en code inscrire et vérifier client
- Code ascii - Guide
- Verifier compatibilite windows 11 - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Filezilla client - Télécharger - Téléchargement & Transfert
1 réponse
Salut. En fait, php te renvoi une erreur "Undefined index" lorsque tu essais d'accéder à un élément qui n'existe pas dans le tableau.
Notice: Undefined index: email
-> l'index "email" n'est pas défini. Il s'agit tu tableau $_POST. En plus tu as un joli message d'erreur : "Adresse mail non valide" qui vient de ce bout de code :
Comme $_POST['email'] n'existe pas, sa marche pas. Je te conseil de toujours vérifier au moins l'existence des variables que tu récupères depuis un formulaire. Du genre au début de ton script, pour chaque variables du formulaire, tu fais :
La fonction isset() permet de vérifier si une variable existe, si elle n'existe pas, tu l'initialise avec une chaine vide par exemple.
Notice: Undefined index: email
-> l'index "email" n'est pas défini. Il s'agit tu tableau $_POST. En plus tu as un joli message d'erreur : "Adresse mail non valide" qui vient de ce bout de code :
if (!strpos($_POST['email'],'@')){
echo'Adresse mail non valide';
}
Comme $_POST['email'] n'existe pas, sa marche pas. Je te conseil de toujours vérifier au moins l'existence des variables que tu récupères depuis un formulaire. Du genre au début de ton script, pour chaque variables du formulaire, tu fais :
if (isset($_POST['email'])) { $email = $_POST['email']; } else { $email = ""; }
La fonction isset() permet de vérifier si une variable existe, si elle n'existe pas, tu l'initialise avec une chaine vide par exemple.
j'ai mise $email=$_POST['email'];
dslée j suis pas assez forte en php je ne suis qu'une débutante :(