Parameter Übergabe

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Parameter Übergabe

    Hallo,
    ersteinmal Danke für eure stetige Hilfe, die mir den Einstieg sehr erleichtert

    Eine Frage habe ich: Könnt ihr mir sagen warum sich beim letzten Formular "ist die Person immer noch..." das erste Formular "was möchtest du tun" mitaufruft, obwohl es nur einmal am Anfang aufgerufen werden soll, solange es "==empty" ist
    Wieso kennt PHP $wastun und $wastunhid beim letzten Formular nicht mehr?Wie kann ich es (effizient) lösen?
    Danke

    PHP-Code:
    <html>
    <body>

    <?


    $wastun=$_POST['wastun'];
    $wastunhid=$_POST['wastunhid'];
    $wensuchen=$_POST['wensuchen'];

    $geschlecht=$_POST['geschlecht'];


                                                                                                     //wastun
    if (empty($wastunhid))

    echo"




    <table border='1' height=100 width=500>
      <tr=>

        <th colspan=3 bgcolor=lightblue >Was m&ouml;chtest Du tun?
    <form action='tab.php' method='Post'>
        </th>

      </tr>
      <tr>
        <td colspan=1 ><input type='radio' name='wastun' value='1'></td>
        <td colspan=1 >Jemanden Suchen</td
      </tr>
      <tr>
        <td colspan=1 ><input type='radio' name='wastun' value='2'></td>
        <td colspan=1 >Profil anlegen</td>

      </tr>
       <tr>
        <td colspan=3 ><input type='submit' value='Abschicken'>
    <input type='reset' value='Reset'>

    </td>


      </tr>
    </table>


    ";
                                                    //geschlecht



    elseif (isset($wastun))

    echo"

    <table border='1' height=100 width=500>
      <tr=>

        <th colspan=3 bgcolor=lightblue >Welches Geschlecht hat die Person?
    <form action='tab.php' method='Post'>
        </th>

      </tr>
      <tr>
        <td colspan=1 ><input type='radio' name='geschlecht' value='1'></td>
        <td colspan=1 >m&auml;nnlich</td>
      </tr>
      <tr>
        <td colspan=1 ><input type='radio' name='geschlecht' value='2'></td>
        <td colspan=1 >weiblich</td>

      </tr>
       <tr>
        <td colspan=3 ><input type='submit' value='Abschicken'>
    <input type='reset' value='Reset'>

    </td>


      </tr>
    </table>



    ";


                                                //wensuchen
    if (isset($geschlecht))
    echo"

    <table border='1' height=100 width=500>
      <tr=>

        <th colspan=3 bgcolor=lightblue >Wen willst Du suchen? $wastunhid
        <form action='tab.php' method='Post'>
       </th>

      </tr>
      <tr>
        <td colspan=1 ><input type='radio' name='wensuchen' value='1'>
        </td>
    ";

    IF (($geschlecht)==1)
    echo"
    <td colspan=1 >Sch&uuml;ler</td>
    </tr>
    ";
    IF (($geschlecht)==2)
    echo"
    <td colspan=1 >Sch&uuml;lerin</td>
    </tr>
    ";

    IF (isset($geschlecht))
    echo"
    <tr>
        <td colspan=1 ><input type='radio' name='wensuchen' value='2'></td>
    ";
    IF (($geschlecht)==1)
    echo"
        <td colspan=1 >Student $wensuchen </td>
    </Tr>
    ";
    IF (($geschlecht)==2)
    echo"
        <td colspan=1 >Studentin</td>
    </tr>
        ";
    if (isset($geschlecht))
    echo"
      </tr>
       <tr>
        <td colspan=3 ><input type='submit' value='Abschicken'>
              <input type='reset' value='Reset'>

        </td>


      </tr>
    </table>




    ";

                                                 //aktuell
    if ((isset($wensuchen))&&(empty($aktuell)))
    echo"

     <table border='1' height=100 width=500>
     <tr>

        <th colspan=3 bgcolor=lightblue >Ist die Person immer noch $wastun ?
        <form action='abl.php' method='Post'>   </th>

      </tr>
      <tr>
        <td colspan=1 ><input type='radio' name='aktuell' value='1'></td>
        <td colspan=1 >Ja</td>
      </tr>
      <tr>
        <td colspan=1 ><input type='radio' name='aktuell' value='2'></td>
        <td colspan=1 >Nein</td>

      </tr>
       <tr>
        <td colspan=3 ><input type='submit' value='Abschicken'>
            <input type='reset' value='Reset'></td>


      </tr>
    </table>
    ";

    echo"

    <input type='hidden' name='wastunhid' value=$wastun>
    </form>
    ";


    ?>

    </html>
    </body>

  • #2
    Zwischen den Formularen musst du die alten Werte mittels hidden-Fields oder Sessions weiterreichen.
    Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

    [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
    Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

    Kommentar


    • #3
      ich habe doch nur EIN "großes" Formular, genügt es nicht die hidden werte einmal am Ende aufzulisten, sonst habe ich ja z.B. bei 50 Formularen später 50 "dicke Blöcke" mit jeweils den alten und einer neuen variable im Skript. Wäre es mit einer Session eleganter gelöst?
      ich hatte es vorher mit hidden gemacht, es kam mir so umständlich vor?

      Kommentar


      • #4
        Wäre es mit einer Session eleganter gelöst?
        imho ganz sicher.
        Gutes Tutorial | PHP Manual | MySql Manual | PHP FAQ | Apache | Suchfunktion für eigene Seiten

        [color=red]"An error does not become truth by reason of multiplied propagation, nor does truth become error because nobody sees it."[/color]
        Mohandas Karamchand Gandhi (Mahatma Gandhi) (Source)

        Kommentar

        Lädt...
        X