Re: $_POST[$variable]

From: Date: Thu, 11 Dec 2003 13:14:23 +0000
Subject: Re: $_POST[$variable]
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-172466@lists.php.net to get a copy of this message
If you change the name of the data field to something[] then the $_POST['something'] will be an array containing your data The code you have will result in 2 fields (one hidden one normal) with the same name ($i), this will cause lots of problems It is not a good idea to give form fields numeric names, "form_field_".$i would be better you need to take care with using _POST - it is accessed like this $_POST['name'] NOT $_POST['$name'] Mike Christian Jancso wrote:
Hi there, I have the following problem: How can I use variables in the $_POST statement? Here is my code: $old_station[$o] = $_POST['$i']; $new_station[$o] = $_POST['$i']; echo "<form name='station_change' method='post' action='station_change.php'>"; echo "<TABLE BORDER=0>"; while ($status_array = mysql_fetch_array($status)) {
        $i++;
        echo "<tr>";
        echo "<td>"."<FONT FACE='Helvetica' SIZE=-1>";
            echo $status_array[1];
        echo "</td>";
        echo "<td>";
            echo "<input type='text' size=2 name='$i'
value='$status_array[1]'>"."<input type='hidden' name='$i' value='$test'>"."<br>";
        echo "</td>";
        echo "</tr>";
} echo "</table>"; echo "<input type='hidden' name='counter' value='$i'>"; echo "<br>"; echo "<br>"; echo "<input type='submit' name='action' value='Change'>"; echo "<input type='submit' name='action' value='Delete'>"; echo "</form>"; can anyone help me? thx for your help Christian


« previous php.general (#172466) next »