Php => $_post

zdoobz Messages postés 34 Statut Membre -  
 Bobby -
salut les gens !
j'ai un probleme trop CON en php plz help!
j'ai ca :
<?
if (($_GET["ok"]) && ($x=1) )
{
if ( (!empty($_GET["nama"])) && (!empty($_GET["pwd"])) )
{
echo "<font color=\"red\"> 2nd too: Welcome $nama </font>";
}
echo "1st works";
?>
et puis cha:

<form action="index.php?x=1" method="post" >
<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#F1F8FF">
<tr>
<td background="titlebckg.png" height="25px"><center>
<b>:LoG:</b>
</center></td>
</tr>
</table>

<table width="100%" cellpadding="0" cellspacing="0" border="0" background="icones/fant.png" style="r">
<tr>
<td>
<center>
<input name="nama" type="text" size="10" value="Nick">
</center>
</td>
</tr>
<tr>
<td style="border-bottom: 1px solid #66CCFF;">
<center>
<input name="pwd" type="password" size="8" ">
<input type="submit" size="2" value="Ok" name="ok" >
</center>
</td>
</tr>
</table>
</form>
dsl pr tt le html ke j'ai inséré mais bon :s si vs pouvez m'aider.. s'il mank des guillements ou koa c pck j'ai viré le css ..
merci !

5 réponses

  1. Oli
     
    Il manque une accolade, le bon code php est le suivant :
    <?

    if (($_GET["ok"]) && ($x==1) )
    {
    if ( (!empty($_GET["nama"])) && (!empty($_GET["pwd"])) )
    {
    echo "<font color=\"red\"> 2nd too: Welcome $nama </font>";
    }
    }
    echo "1st works";
    ?>
    0
  2. Oli
     
    ou plutôt (plus adapté au code, je crois) :
    <?php

    if (($_GET["ok"]) && ($x==1) )
    {
    if ( (!empty($_GET["nama"])) && (!empty($_GET["pwd"])) )
    {
    echo "<font color=\"red\"> 2nd too: Welcome $nama </font>";
    }

    echo "1st works";

    }
    ?>
    0
  3. Oli
     
    Petite remarque, pour que le code fonctionne, il faut utiliser l'array $_POST au lieu de $_GET pour tester les variables, puisque la méthode du form est post et non get ;-)
    0
  4. zdoobz
     
    vi j'ai vu mais en faite ds mon code elle y a l'accolade..
    serait ce une erreur de syntax..?
    0
  5. Vous n’avez pas trouvé la réponse que vous recherchez ?

    Posez votre question
  6. Bobby
     
    dans le formulaire la mthode est POST et pas get ici:

    method="post" puisque tu récupère les données en POST, ou alors tu fais tout en GET (get=affiché dans la barre da'dresse)

    tchao
    0