Code php
amoure
-
Utilisateur anonyme -
Utilisateur anonyme -
j'ai un probleme au niveau de mon code php lorsque je saisie les données dans mes champs j'obtien ces erreurs:
Notice: Undefined index: file in C:\wamp\www\projet\tontine\creer_menbre.php on line 7
Notice: Undefined index: file in C:\wamp\www\projet\tontine\creer_menbre.php on line 8
Notice: Undefined index: file in C:\wamp\www\projet\tontine\creer_menbre.php on line 9
j'arrive pas les corriger et j'ai besoin de votre aide voici mon codes merci.
EDIT: Ajout de la coloration syntaxique.
Notice: Undefined index: file in C:\wamp\www\projet\tontine\creer_menbre.php on line 7
Notice: Undefined index: file in C:\wamp\www\projet\tontine\creer_menbre.php on line 8
Notice: Undefined index: file in C:\wamp\www\projet\tontine\creer_menbre.php on line 9
j'arrive pas les corriger et j'ai besoin de votre aide voici mon codes merci.
<?php include('fonctconnect.php'); //make code insert image to database if (isset($_POST['save'])) { if(($_FILES['file']['type'] == 'image /gif') || ($_FILES['file']['type'] == 'image /jpeg') || ($_FILES['file']['type'] == 'image/pjpeg') && ($_FILES['file']['size'] < 200000 )) { if ($_FILES['file']['error'] > 0) { echo "return code:" . $_FILES['file']['error']; } else if (file_exits('upload/'. $_FILES['file']['name'])) { echo $_FILES['file'] ['name']."Already Exit"; } else if (move_uploaded_file($_FILES['file']['tmp_name'],'upload/'.$_FILES['file']['name'])) { $part = $FILES['file']['name']; $sql = mysql_query("INSERT INTO menbres (nom,prenom,telephone,cni,sexe,age,photo,status) VALUES('{$POST['nom']}','{$POST['prenom']}','{$POST['telephone']}','{$POST['cni']}',' {$POST['sexe']}','{$POST['age']}','{$part}','{$POST['status']}')"); if ($sql) { echo "successfully insert this record...."; } } } } //end ?> <!doctype html> <html> <head> <meta charset="UTF-8"/> <title>tontine</title> <link rel="stylesheet" type="text/css" href="style.css"> </head> <body> <div> <div id="entete"> <img src="images/vie.png" class="tontine"/> <div id="nav"> <ul> <li><span class="home"></span><a href="index.php">Accueil</a></li> <li><span class="menbre"></span><a href="menbres.php">Menbres</a></li> <li><span class="consul"></span><a href="#">Gestion</a></li> <li><span class="search"></span><a href="#">Chercher</a></li> <li><span class="back"></span><a href="#">Configuration</a></li> <li><span class="actua"></span><a href="#">Options</a></li> <li><span class="print"></span><a href="#">Details</a></li> <li><span class="aide"></span><a href="#">Aides</a></li> </div> </div> <div style=""></div> <div id="contenu" > <div class='divcont'style="overflow:auto;"> <div style="border:1px #000 dotted; width:100%;height:80px;text-align:center;line-height:20px;font-size:36px;color:#f00;background:#eee"> <p style="line-height:20px;">TABLE MENBRE</p> </div> <div style="border:1px #000 dotted; width:100%;overflow:auto; background:#eee;"> <center> <form action="creer_menbre.php" method="post" enctype="multipart/form-data"> <table> <tr> <td>Nom</td> <td><td> <td><input type="text" name="nom" value="" /></td> </tr> <tr> <td>Sexe</td> <td><td> <td> <select name="sexe" style="width:149px;"> <option value="0">Masculin</option> <option value="1">Feminin</option> </select> </td> </tr> <tr> <td>Date de naissance</td> <td><td> <td><input type="date" name="field1" id="field1" value="" /></td> </tr> <tr> <td>Age</td> <td><td> <td><input type="text" name="age" value="" /></td> </tr> <tr> <td>Telephone</td> <td><td> <td><input type="text" name="telephone" value="" /></td> </tr> <tr> <td>Cni</td> <td><td> <td><input type="text" name="cni" value="" /></td> </tr> <tr> <td>Status</td> <td><td> <td><input type="radio" name="status" value="salarie" />Salarié <input type="radio" name="status" value="commerçant" />Commerçant <input type="radio" name="status" value="etudiant" />Retraiter </td> </tr> </table> <input type="submit" value="save" name="save"/> </form> </center> <table style="border:1px solid #000;width:100%;"> <thead> <th>N° menbre</th> <th>Nom</th> <th>Genre</th> <th>Date_naissance</th> <th>Telephone</th> <th>Status</th> <th>Cni</th> <th>Photo</th> </thead> </table> </div> <?php connect(); ?> </div> <div class="lien"><a href="menbres.php">retour à la page précedente</a></div> </div> <div style="margin-bottom:3px;"></div> <div id="pied"> Dévéloppée par blondel<br />Copyright@InfoSoft 2015. Tout droit reservé </div> </body> </html>
EDIT: Ajout de la coloration syntaxique.
A voir également:
- Code php
- Code ascii - Guide
- Code puk bloqué - Guide
- Code activation windows 10 - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code blocks - Télécharger - Langages
2 réponses
Bonjour
Ne masque jamais les "notice", corrige les erreurs.
Tu as cette erreur parce que tu fais comme si tu téléchargeais un fichier, mais il n'y a aucun champ pour choisir ce fichier dans ton formulaire. Tu devrais avoir un input de type file et aussi de name 'file'. C'est ce name que tu retrouveras dans $_FILES quand tu l'auras créé.
Ne masque jamais les "notice", corrige les erreurs.
Tu as cette erreur parce que tu fais comme si tu téléchargeais un fichier, mais il n'y a aucun champ pour choisir ce fichier dans ton formulaire. Tu devrais avoir un input de type file et aussi de name 'file'. C'est ce name que tu retrouveras dans $_FILES quand tu l'auras créé.
L'index type n'est pas défini dans $_FILES['file']['type']
Il ne s'agit pas vraiment d'une erreur mais d'une "notice", tu peux masquer ces erreurs dans la config PHP
Regarde ici : https://forums.commentcamarche.net/forum/affich-37636387-php-notice-undefined-index
Il ne s'agit pas vraiment d'une erreur mais d'une "notice", tu peux masquer ces erreurs dans la config PHP
Regarde ici : https://forums.commentcamarche.net/forum/affich-37636387-php-notice-undefined-index