Jump to content

[PHP] $_POST Variable


Recommended Posts

Hi

i got a problem to get some variable from a form

i set the variable with

<input type=\"hidden\" name=\"maxt1\" size=\"40\">

<input type=\"hidden\" name=\"maxt2\" size=\"40\">

<input type=\"hidden\" name=\"maxt3\" size=\"40\">

and send them with post to the next file.

action="xml.php?id=3"

in the new file i will echo all files but don´t know the way i tried this

for $i = 0; $i <=$_GET['id']; $i++)

{

echo $_POST['maxt$i'];

}

but the varialbes are empty ?

whats the misstake i made ?

thx

darph

Link to comment
Share on other sites


Hi Darph

The problem as i see it lies with the following bit of code.

<input type=\"hidden\" name=\"maxt1\" size=\"40\">
<input type=\"hidden\" name=\"maxt2\" size=\"40\">
<input type=\"hidden\" name=\"maxt3\" size=\"40\">

although you have set the variables you haven't actually given them a value so you should change the above to something like below.

<input type=\"hidden\" name=\"maxt1\" size=\"40\" value=\"1\">
<input type=\"hidden\" name=\"maxt2\" size=\"40\" value=\"2\">
<input type=\"hidden\" name=\"maxt3\" size=\"40\" value=\"3\">

By adding the value attribute to the input tag you are giving the variables a value so when you echo the variables using the code in the other file you will get the following.

123

Hope that helps

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...