IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

POST['var'] qui ne marche pas


Sujet :

Langage PHP

  1. #1
    Membre confirmé
    Inscrit en
    Octobre 2007
    Messages
    162
    Détails du profil
    Informations forums :
    Inscription : Octobre 2007
    Messages : 162
    Par défaut POST['var'] qui ne marche pas
    j'ai un probleme avec la mise à jour des tables dans mysql voici le code
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
     
     
    if ($_GET['act']=="mod"){
    $i=$_GET['id']; // le id est récuperer
    $title=$_POST['titre'];// PROBLEMES: la valeur $title reste null
    $dtl=$_POST['dtl'];
    $dbu=$_POST['debut'];
    $f=$_POST['fin'];
    mysql_query("update promo set Titre='$title',Detail='$dtl',Date_debut='$dbu',Date_fin='$f' where Id_promo='$i'");
    }
    <a href="?act=supr&id=<?=$news['Id_promo']?>&p=<?=$_GET['p']?>">Supprimer</a>-<a href="?act=mod&id=<?=$news['Id_promo']?>&p=<?=$_GET['p']?>">Modifier</td>
    Quand je mets echo à la valeur par exemple $title rien ne s'affiche pas car le $_POST['titre'] est vide et c'est la même chose pour tous les autre variable. merci de me répondre.

  2. #2
    Membre Expert
    Avatar de Seb33300
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2007
    Messages
    1 564
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Thaïlande

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 564
    Par défaut
    D'où récupères tu ces valeurs ? d'un formulaire ?

    On peut avoir le code html du formulaire ?

  3. #3
    Membre confirmé
    Inscrit en
    Octobre 2007
    Messages
    162
    Détails du profil
    Informations forums :
    Inscription : Octobre 2007
    Messages : 162
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
     
    <html>
    <head><title>Ajouter des promotions</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link href="layout.css" rel="stylesheet" type="text/css" /></head>
    <?
    error_reporting(0);
     include "inc/config.php";
    include  "inc/pagination.php";
     ?>
     <body >
    <form name="f1" method="POST" action="#">
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <table><tr><td>Titre:<td><input type="text" maxlength="26" name="titre" >
    <center><tr><td>Du<td> <input value="2000-01-01" maxlength="255" name="debut"></td></tr>
    <tr><td>au:<td> <input value="2000-01-01" maxlength="255" name="fin" ></td>
    <tr><th rowspan="2">Détail: </th><td>  <TEXTAREA NAME="dtl" COLS=40 ROWS=6>Entrer le détail de votre promotion...</TEXTAREA>
    </td></tr>
    </table>
    <input type="submit" name="send" value="ajouter">
    <?
    if ($_POST['send']=="ajouter"){
    $title=$_POST['titre'];
    $dtl=$_POST['dtl'];
    $dbu=$_POST['debut'];
    $f=$_POST['fin'];
    echo "enregistrement effectuer";
    mysql_select_db("0963",$conn);
    mysql_query("insert into promo values ('','$title','$dtl','$dbu','$f')");
    }
    if ($_GET['act']=="mod"){
    $i=$_GET['id'];
    $title=$_POST['titre'];
    $dtl=$_POST['dtl'];
    $dbu=$_POST['debut'];
    $f=$_POST['fin'];
    mysql_query("update promo set Titre='$title',Detail='$dtl',Date_debut='$dbu',Date_fin='$f' where Id_promo='$i'");
    echo "Modifier" . $i . $title;
    }
    if ($_GET['act']=="supr"){
    $i=$_GET['id'];
    mysql_query("delete from promo where Id_promo='$i'");
    echo "Promotion supprimer avec succés";
    }
     
    ?>
    <?
    	$sql = "SELECT * FROM promo"; 
    	$url = $_SERVER['PHP_SELF']."?p=";
    	$total = mysql_query($sql); 
    	$nblignes = mysql_num_rows($total);
    	$nbpages = ceil($nblignes/$parpage);
     
    	$result = reqlimit($nblignes,$parpage,$sql);
    	?><table width="652" border="0" align="center">
    <tr>
            <td width="38" bgcolor="#CAFFFF">id</td>
          <td width="61" bgcolor="#CAFFFF">Titre</td>
          <td width="95" bgcolor="#CAFFFF">Date d&eacute;but</td>
          <td width="146" bgcolor="#CAFFFF">Date fin</td>
          <td width="146" bgcolor="#CAFFFF">Détails</td>
          <td width="140" bgcolor="#CAFFFF">Action</td>
        </tr>
        <?  while ($news = mysql_fetch_array($result)) {?>
          <tr>
            <td bgcolor="#CCCCCC"><? echo $news['Id_promo']; ?></td>
            <td bgcolor="#CCCCCC"><? echo $news['Titre']; ?></td>
            <td bgcolor="#CCCCCC"><? echo $news['Date_debut']; ?></td>
            <td bgcolor="#CCCCCC"><? echo $news['Date_fin']; ?></td>
            <td bgcolor="#CCCCCC"><? echo $news['Detail']; ?></td>
            <td bgcolor="#CCCCCC"><a href="?act=supr&id=<?=$news['Id_promo']?>&p=<?=$_GET['p']?>">Supprimer</a>-<a href="?act=mod&id=<?=$news['Id_promo']?>&p=<?=$_GET['p']?>">Modifier</a></td>
          </tr><? }?>
      </table>
      <?
    	echo "<center>";
    	echo pagination($url,$parpage,$nblignes,$nbpages);
    	echo "</center>";
    	mysql_free_result($result);
    	?>
     
    </form>
    </body>
    </html>

  4. #4
    Membre Expert
    Avatar de Seb33300
    Homme Profil pro
    Développeur Web
    Inscrit en
    Janvier 2007
    Messages
    1 564
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 40
    Localisation : Thaïlande

    Informations professionnelles :
    Activité : Développeur Web
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Janvier 2007
    Messages : 1 564
    Par défaut
    enlève le # de action dans ton form

Discussions similaires

  1. logiciel avec BD, qui ne marche pas sur d'autres postes
    Par nassimanocus dans le forum Débuter
    Réponses: 9
    Dernier message: 15/02/2014, 05h24
  2. .bat qui ne marche pas sur tout les postes
    Par guismoman33 dans le forum Scripts/Batch
    Réponses: 1
    Dernier message: 06/08/2008, 11h52
  3. Iptables configuration qui ne marche pas....
    Par The_Nail dans le forum Sécurité
    Réponses: 7
    Dernier message: 03/02/2004, 14h27
  4. Réponses: 3
    Dernier message: 08/09/2003, 15h06
  5. Réponses: 9
    Dernier message: 07/05/2003, 12h57

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo