Hi All

I have a problem with a a page with 2 forms on it.

The first form controls the input from a drop down list and the second has a series of text boxes.

When I submit the form I cannot get any values from the second form. I'm currently modifying someone elses code and have addded the second form.

Text boxes are named but appear in the url, whihc is strange as the form is post - this is, however, nested in another form that is get. Can this be done ?

I've tried switching both forms to get and extracting the value from the url but although it is visible in the url I still get nothing.

The code to check the submit is:

if($_POST['submit'] == 'process') {   echo "process"; }
print "value: ".$_POST['negValue']."\r\n";

The form def is:

<form name="choose_c" action="'.$newLocation.'" method="get">
<form name="process" action ="" method="post">

And the input text boxes are defined as:

$negAmount = '<input type="text" value="'.$invoice["amount"].'" name="negValue" id="'.$invoice["payment_ref"].'" /> ';

The submit button looks like this:

<tr><td><input type="submit" value="Update" action="document.forms[1].submit()"/></td></tr>

Is the problem due to the fact that the forms are nested with GET and POST ?
$negAmount is always empty on submit ...

Cheers

Steve

I find that your expanation of the problem is hard to understand. If you are trying to nest one form within another, I'm pretty sure that won't work. you mention nesting so I'm guessing that is what you tried to do.

If you have two independent forms on a page that will work but it will only give the results for the form that was submitted (not both). If you need the results from both sections (with one submit), then you should merge the fields into one form.

If you are trying something else, then it would be helpful to restate clearly what you are trying to do.

I find that your expanation of the problem is hard to understand. If you are trying to nest one form within another, I'm pretty sure that won't work. you mention nesting so I'm guessing that is what you tried to do.

If you have two independent forms on a page that will work but it will only give the results for the form that was submitted (not both). If you need the results from both sections (with one submit), then you should merge the fields into one form.

If you are trying something else, then it would be helpful to restate clearly what you are trying to do.

I see your point - I just read it again and it is a bit jumbled.

I have the script working now but only after I removed the GET form.
What I have is this (in a wierd kind of psuedocode):

<FORM METHOD=GET>
<FORM METHOD=POST>
<TABLE>
<TEXT BOXES NAME=boxes>
<SUBMIT BUTTON ACTION=submit post form>
</TABLE>
</FORM POST>
</FORM GET>

If I remove the GET FORM then I get POST values, if I leave it there I get nothing ...

Ideally I need both but don't want the POST vars visible in the URL.
The last time I was using PHP I used simple forms that posted to themselves and never had a problem. That was a while ago though ...
Hope this is clearer

Steve

Member Avatar for Rkeast

Why are you needing to have one form use GET and the other use POST, can you not use POST to send all of the data?

I am having trouble understanding the reasoning for having a system like that. Could you explain in detail what your setup is like and why you're doing the forms that way?

It's not my system. It's work another contractor did - the main problem being an include of a select list that relies on GET values. I 'fixed' it by using a single form with post and working around all the other problems. I can't explain why he did it like that but it's a big system and it's not the first time I've come across things that are a bit odd.

Thanks for your help

Steve

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.