Page 1 of 1

Question about $_POST

Posted: Sat Mar 01, 2008 5:56 pm
by thsmrtone1
I'm having difficulty with this one statement in my code... Hopefully someone can tell me where I went wrong.

This works:

Code: Select all

$input = $_POST["value_1"]; //returns correctly
But this doesnt:

Code: Select all

$myval = "value_1";
$input = $_POST[$myval]; //returns NULL
Is there something that makes it so that you cannot input a variable into $_POST?

Re: Question about $_POST

Posted: Thu Mar 06, 2008 2:11 pm
by francisjeffy
Hi,

It is possible to input a variable into $_POST

See the code below

Code: Select all

<?php
    if(isset($_POST[btn_submit])){
        $name2 = "name";
        $name = $_POST[$name2];
        echo "Name: ".$name;
    }
?>
<form method="POST" action="">
    <table>
        <tr>
            <td>
                <input type="hidden" name="name" value="jeF">
                <input type="submit" name="btn_submit">
            </td>
        </tr>
    </table>
</form>
Hope it helps,

Kind Regards,

jeF