Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    [php] passaggio dati da form a file .php

    io ho questa pagina:

    codice:
    <?
    include("config.inc.php");
    $query = mysql_query("SELECT id, nome FROM sezione ORDER BY id ASC", $db);
    ?>
    <html>
    <head>
    <title>Documento senza titolo</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    
    <body>
    <h3>Crea una nuova sezione!</h3>
    <form action="addsection2.php" method="post">
    Nome: <input type="text" name="nome">
    
    Logo: <input type="text" name="logo" value="http://">
    
    
    <input type="hidden" name="id_sez" value="0">
    <input type="submit" value="Crea Sezione">
    </form>
    
    
    
    <h3>Crea una sotto sezione!</h3>
    <form action="addsection.php" method="post">
    Nome: <input type="text" name="nome">
    
    Logo: <input type="text" name="logo" value="http://">
    Sotto Sezione di: <select name="id_sez">
    <?
    while ( $s = mysql_fetch_array($query) ) {
    	echo "<option value=\"$s[id]\">$s[nome]</option>"
    }
    ?>
    </select>
    </form>
    
    </body>
    </html>
    Come vedete ci sono 2 form che puntano alla stessa pagina che inserira i dati nel DB...
    se uno usa il secondo form tutto ok. pero se usa il primo ho paura che succedano dei casini... perche io nel secondo file che creerà la sezione ho messo:

    $id_sez = $_POST["id_sez"];

    e quel select che manda i dati non c'è nel primo form quindi in teoria $_POST["id_sez"] non esiste... non è che mi da degli errori?

    per ovviare il problema ( sempre che esista ) come dovrei farE? apparte mandare i dati del 2 form ad un altra pagina :P

  2. #2
    ooooooooooooooooooooooook avevo già ovviato il problema ma ovviamente la mia mente non ricorda cosa aveva fatto 2 secondi prima dsudhusadhsaudhsadu avevo già messo un campo hidden con value 0 =D oddio so proprio cotto

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.