Multi form php/mysql et 1 seul fait son update...

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Multi form php/mysql et 1 seul fait son update...

Re: Multi form php/mysql et 1 seul fait son update...

par xTG » 13 sept. 2013, 22:16

Mets en commentaire les header et ajoutes des echo de debug.
Et notamment regarde le retour de chaque requête, voir des erreurs avec mysql_error().

Re: Multi form php/mysql et 1 seul fait son update...

par ezeccamen » 13 sept. 2013, 21:53

Malheureusement cela ne fonctionne pas plus

http://traiteurpourvous.com/gestionw/in ... nugarderie

Re: Multi form php/mysql et 1 seul fait son update...

par Aureusms » 13 sept. 2013, 21:07

Si tu écris :
if (!empty($_POST['submit2'])) {
il vérifiera si la super variable _POST existe et qu'elle contient une clé 'submit2' qui ne soit pas NULL, égale à 0 ou False.
Le ! permet de dire : si "pas vide" ie. si pas NULL ou pas 0 ou pas False

Re: Multi form php/mysql et 1 seul fait son update...

par ezeccamen » 13 sept. 2013, 19:58

Merci de la réponse!

Comment est-ce que je peux adapter le empty()

Car il y a toujours du contenu dans chacun des input

Re: Multi form php/mysql et 1 seul fait son update...

par xTG » 13 sept. 2013, 13:13

if ($_POST['submit1']){
Ce n'est pas un test valable.
Si tu tentes de vérifier l'existence de la variable il faut utiliser la fonction isset().
Si tu tentes de vérifier son existence et qu'elle n'est pas vide c'est la fonction empty().

Re: Multi form php/mysql et 1 seul fait son update...

par ezeccamen » 12 sept. 2013, 21:40

En fait pour vous avisé j'ai aussi essayé de séparé individuellement chaque pages: menugarderie1.php menugarderie2.php avec des classes menugarderie1_class.php menugarderie2_class.php.
Aussi avec les action="menugarderie1_modify.php" dans les form...

Je galère trop :(

Multi form php/mysql et 1 seul fait son update...

par ezeccamen » 12 sept. 2013, 21:34

Ca fait maintenant 1 semaine que j'essais 50 000 méthodes de règler mon problème.
En espérant une bonne aide de votre part sur ce truc:

J'ai un fichier menugarderie.php
</head>

<body>
<?php include ('header.php'); ?>
<?php $page = 'menugarderie'; include('navbar.php'); ?>
<?php include ('menugarderie_class.php'); ?>
<h2 class="art-postheader">Menu garderie</h2><HR>
<?php include ('procmd.php'); $requete = "SELECT * FROM garderie1 WHERE id='1'"; $result = mysql_query($requete); $data1 = mysql_fetch_array($result); mysql_close(); ?>
<div class="art-postcontent">
<form method="post" name="modify1">
<input name="id" type="hidden" id="id" value="<?php echo $data1['id']; ?>">
<h5 class="art-postheader">Semaine 1 : <input type="text" name="tisem" id="tisem" style="width:600px;background-color:#A6E0FF;font-size:18px" value="<?php echo $data1['tisem']; ?>" /></h5>
<div id="menus" align="center">                                              
<table width="100%" class="art-article" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <td width="10%"><p align="center">Journ&eacute;es:</p></td>
    <td width="15%"><p align="center">Lundi</p></td>
    <td width="15%"><p align="center">Mardi</p></td>
    <td width="15%"><p align="center">Mercredi</p></td>
    <td width="15%"><p align="center">Jeudi</p></td>
    <td width="15%"><p align="center">Vendredi</p></td>
  </tr>
</table>
<table width="100%" class="art-article" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <td width="10%"><p align="center">D&icirc;ner:</p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinlun" id="dinlun" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data1['dinlun']; ?>" cols="20" datas="10"><?php echo $data1['dinlun']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinmar" id="dinmar" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data1['dinmar']; ?>" cols="20" datas="10"><?php echo $data1['dinmar']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinmer" id="dinmer" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data1['dinmer']; ?>" cols="20" datas="10"><?php echo $data1['dinmer']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinjeu" id="dinjeu" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data1['dinjeu']; ?>" cols="20" datas="10"><?php echo $data1['dinjeu']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinven" id="dinven" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data1['dinven']; ?>" cols="20" datas="10"><?php echo $data1['dinven']; ?></textarea></p></td>
  </tr>
</table>
<table width="100%" class="art-article" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <td width="10%"><p align="center">Dessert:</p></td>
    <td width="15%"><p align="center"><textarea type="text" name="deslun" id="deslun" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data1['deslun']; ?>" cols="20" datas="10"><?php echo $data1['deslun']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="desmar" id="desmar" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data1['desmar']; ?>" cols="20" datas="10"><?php echo $data1['desmar']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="desmer" id="desmer" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data1['desmer']; ?>" cols="20" datas="10"><?php echo $data1['desmer']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="desjeu" id="desjeu" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data1['desjeu']; ?>" cols="20" datas="10"><?php echo $data1['desjeu']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="desven" id="desven" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data1['desven']; ?>" cols="20" datas="10"><?php echo $data1['desven']; ?></textarea></p></td>
  </tr>
</table>
</div>
<p align="center"><input type="text" name="text" id="text" style="width:920px;background-color:#A6E0FF;font-size:14px" value="<?php echo $data1['text']; ?>" /></p>
<br/>
<p align="center"><span class="art-button-wrapper"><span class="art-button-l"> </span><span class="art-button-r"> </span> <input class="art-button" type="submit" name="submit1" onmouseover="this.style.cursor='pointer';" value="Enregistrer" /></span></p>
</form>
</div><hr/>
<?php include ('procmd.php'); $requete = "SELECT * FROM garderie2 WHERE id='1'"; $result = mysql_query($requete); $data2 = mysql_fetch_array($result); mysql_close(); ?>
<div class="art-postcontent">
<form method="post" name="modify2">
<input name="id" type="hidden" id="id" value="<?php echo $data2['id']; ?>">
<h5 class="art-postheader">Semaine 2 : <input type="text" name="tisem" id="tisem" style="width:600px;background-color:#A6E0FF;font-size:18px" value="<?php echo $data2['tisem']; ?>" /></h5>
<div id="menus" align="center">                                              
<table width="100%" class="art-article" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <td width="10%"><p align="center">Journ&eacute;es:</p></td>
    <td width="15%"><p align="center">Lundi</p></td>
    <td width="15%"><p align="center">Mardi</p></td>
    <td width="15%"><p align="center">Mercredi</p></td>
    <td width="15%"><p align="center">Jeudi</p></td>
    <td width="15%"><p align="center">Vendredi</p></td>
  </tr>
</table>
<table width="100%" class="art-article" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <td width="10%"><p align="center">D&icirc;ner:</p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinlun" id="dinlun" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data2['dinlun']; ?>" cols="20" datas="10"><?php echo $data2['dinlun']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinmar" id="dinmar" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data2['dinmar']; ?>" cols="20" datas="10"><?php echo $data2['dinmar']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinmer" id="dinmer" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data2['dinmer']; ?>" cols="20" datas="10"><?php echo $data2['dinmer']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinjeu" id="dinjeu" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data2['dinjeu']; ?>" cols="20" datas="10"><?php echo $data2['dinjeu']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="dinven" id="dinven" style="width:125px;background-color:#A6E0FF;height:250px;font-size:16px" value="<?php echo $data2['dinven']; ?>" cols="20" datas="10"><?php echo $data2['dinven']; ?></textarea></p></td>
  </tr>
</table>
<table width="100%" class="art-article" border="1" cellspacing="0" cellpadding="2">
  <tr>
    <td width="10%"><p align="center">Dessert:</p></td>
    <td width="15%"><p align="center"><textarea type="text" name="deslun" id="deslun" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data2['deslun']; ?>" cols="20" datas="10"><?php echo $data2['deslun']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="desmar" id="desmar" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data2['desmar']; ?>" cols="20" datas="10"><?php echo $data2['desmar']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="desmer" id="desmer" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data2['desmer']; ?>" cols="20" datas="10"><?php echo $data2['desmer']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="desjeu" id="desjeu" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data2['desjeu']; ?>" cols="20" datas="10"><?php echo $data2['desjeu']; ?></textarea></p></td>                                     
    <td width="15%"><p align="center"><textarea type="text" name="desven" id="desven" style="width:125px;background-color:#A6E0FF;height:120px;font-size:16px" value="<?php echo $data2['desven']; ?>" cols="20" datas="10"><?php echo $data2['desven']; ?></textarea></p></td>
  </tr>
</table>
</div>
<p align="center"><input type="text" name="text" id="text" style="width:920px;background-color:#A6E0FF;font-size:14px" value="<?php echo $data2['text']; ?>" /></p>
<br/>
<p align="center"><span class="art-button-wrapper"><span class="art-button-l"> </span><span class="art-button-r"> </span> <input class="art-button" type="submit" name="submit2" onmouseover="this.style.cursor='pointer';" value="Enregistrer" /></span></p>
</form>
</div><hr/>
Et voici mon fichier menugarderie_class.php
<?php 
if ($_POST['submit1']){
include ('procmd.php');
$id=$_POST['id'];
$tisem=$_POST['tisem'];
$dinlun=$_POST['dinlun'];
$dinmar=$_POST['dinmar'];
$dinmer=$_POST['dinmer'];
$dinjeu=$_POST['dinjeu'];
$dinven=$_POST['dinven'];
$deslun=$_POST['deslun'];
$desmar=$_POST['desmar'];
$desmer=$_POST['desmer'];
$desjeu=$_POST['desjeu'];
$desven=$_POST['desven'];
$text=$_POST['text'];
mysql_query("UPDATE garderie1 SET tisem='$tisem', dinlun='$dinlun', dinmar='$dinmar', dinmer='$dinmer', dinjeu='$dinjeu', dinven='$dinven', deslun='$deslun', desmar='$desmar', desmer='$desmer', desjeu='$desjeu', desven='$desven', text='$text' WHERE id='$id'");
header("location:http://traiteurpourvous.com/gestionw/index.php?page=menugarderie");
}

if ($_POST['submit2']){
include ('procmd.php');
$id=$_POST['id'];
$tisem=$_POST['tisem'];
$dinlun=$_POST['dinlun'];
$dinmar=$_POST['dinmar'];
$dinmer=$_POST['dinmer'];
$dinjeu=$_POST['dinjeu'];
$dinven=$_POST['dinven'];
$deslun=$_POST['deslun'];
$desmar=$_POST['desmar'];
$desmer=$_POST['desmer'];
$desjeu=$_POST['desjeu'];
$desven=$_POST['desven'];
$text=$_POST['text'];
mysql_query("UPDATE garderie2 SET tisem='$tisem', dinlun='$dinlun', dinmar='$dinmar', dinmer='$dinmer', dinjeu='$dinjeu', dinven='$dinven', deslun='$deslun', desmar='$desmar', desmer='$desmer', desjeu='$desjeu', desven='$desven', text='$text' WHERE id='$id'");
header("location:http://traiteurpourvous.com/gestionw/index.php?page=menugarderie");
}
?>
Mon premier form fonctionne à merveille mais mon deuxieme n'Update pas dutout...
Le SELECT m'affiche toutes mes données.