f



php assembly of multiple php files

I am trying to combine multiple php pages into 1.

Basically I have created a shell page and then a seperate php file for
each form to be included within the shell.

The problem I am having is that when a user submits one of the forms
the main shell and the other php files POST values are all returned as
NULL and I only get the values pertaining to the form that was
submitted?.  If all the files were combined into one very long php
file, I would get all the POSTs returned how can I do the same but
with multiple files?

When you submit an include, do the POST values not get passed back to
the Main calling page?

Thank you,

QB
0
6/11/2009 11:38:17 AM
comp.lang.php 32646 articles. 0 followers. Post Follow

2 Replies
1333 Views

Similar Articles

[PageSpeed] 45

Question Boy wrote:
> I am trying to combine multiple php pages into 1.
> 
> Basically I have created a shell page and then a seperate php file for
> each form to be included within the shell.
> 
> The problem I am having is that when a user submits one of the forms
> the main shell and the other php files POST values are all returned as
> NULL and I only get the values pertaining to the form that was
> submitted?.  If all the files were combined into one very long php
> file, I would get all the POSTs returned how can I do the same but
> with multiple files?
> 
> When you submit an include, do the POST values not get passed back to
> the Main calling page?
> 
> Thank you,
> 
> QB

This has nothing to do with PHP - it's how HTML works.  The browser will 
only send the data for the form being submitted - not any other forms on 
the page.  Combining them into one long file yet maintaining separate 
forms will not change that.

The other values are not NULL, they are not set.  There is a difference!


-- 
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
0
jstucklex (14659)
6/11/2009 11:54:13 AM
On Jun 11, 12:38=A0pm, Question Boy <question....@hotmail.com> wrote:
> I am trying to combine multiple php pages into 1.
>
> Basically I have created a shell page and then a seperate php file for
> each form to be included within the shell.
>
> The problem I am having is that when a user submits one of the forms
> the main shell and the other php files POST values are all returned as
> NULL and I only get the values pertaining to the form that was
> submitted?. =A0If all the files were combined into one very long php
> file, I would get all the POSTs returned how can I do the same but
> with multiple files?
>
> When you submit an include, do the POST values not get passed back to
> the Main calling page?
>
> Thank you,
>
> QB

Put a hidden input in each form with the same name and a value which
identifies the form, e.g.

<form>
<input type=3D'hidden' name=3D'whichform' value=3D'emailaddr'>
Email address <input type=3D'text' name=3D'emailaddr' value=3D'<?php print
$emailaddr; />
<input type=3D'submit' value=3D'go'>
</form>
<form>
<input type=3D'hidden' name=3D'whichform' value=3D'name'>
Name <input type=3D'text' name=3D'emailaddr' value=3D'<?php print $name; />
<input type=3D'submit' value=3D'go'>
</form>
<form>
<input type=3D'hidden' name=3D'whichform' value=3D'telno'>
<input type=3D'text' name=3D'emailaddr' value=3D'<?php print $telno; />
<input type=3D'submit' value=3D'go'>
</form>
.....

Then in the page which process the response.....

switch($_REQUEST['whichform']) {
  case 'emailaddr':
  case 'name':
  case 'telno':
    ${$_REQUEST['whichform']}=3D${$_REQUEST[$_REQUEST['whichform']]};
    break;
}

(obviously you'd want to change this a bit to accomodate multiple
fields in a form).

Alternatively, don't put <form>...</form> tags in the individual
forms, but rather enclose all the files in the tags at the shell
script level.

Alternatively, ignore the NULL responses (by checking arry_key_exists
($_REQUEST, $name_unique_to_this_form))

Not hard.

C.
0
6/11/2009 1:04:35 PM
Reply: