Web Hosting Talk







View Full Version : Include a file, and not at the same time...impossible?


UrlGuy
04-01-2005, 05:01 PM
Hi,

I got this file, "make.php", which i do a POST request to with some info, which output some more info. The request are being sent from "index.php". I want to include index.php on the top of "make.php" so the result of "make.php" would appear below the form in "index.php", but "index.php" contains a footer with a little explenation, which I would not like to include after the POST are being made, so it doesnt show the form at top, then the footer, then the result.. that would look stupid, neither do I want the POST results to appear on another page, but rather keep the POST result to appear below the form in "index.php" so the user can quickly type in more info to submit it again, without clicking the back button.

Hope anyone can help, if this thing are possible at all. Any help greatly apprecciated, thanks.

samdax
04-01-2005, 05:27 PM
as I inderstand you can not do that in way you explain.
If you want to show post result from first page to second page just use
<?php echo $_POST['name_of_form_field'];?>
if you want to proceed this result to another page
<input type='hidden' name='new_name_whatever_you_want' value='<?php echo $name_of_form_field;?>'>
and finaly if you want to show form fields from first page in second page with results submited from first form but user still can change that info (value defined) then use
value='<?php echo $dname_of_form_field;?>'

Anyway
You can not include page with submited results in another page, but you can include results only

Shockrift
04-01-2005, 11:26 PM
Very simple process. I cannot fully explain it due to time constraints, but the groundwork is relatively simple.
The header, content (form), result (if applicable -- form submission), footer, would all have to be stored in seperate variables rather than outputting them directly. Then something along the lines of:


if($_SERVER['REQUEST_METHOD']=='POST'){
if($_POST['age'] < 13){
$response[] = 'only teenagers allowed!'
}
if(is_array($response)){
echo $form . '<br /><hr /><br />The following responses were given to the form:<br /><ul>';
foreach($response as $k => $v){ echo "<li>$v</li>"; }
} else {
echo $form;
}
} else {
echo $form;
}
echo $footer;


sorry I can't go into this further with you. Best of luck!