View Full Version : Server side includes don't work with good_template
wardw
10-09-2009, 11:27 AM
When a user submits my form I'd like to display an acknowledgement page that shows the form data as a confirmation. The acknowledgment page appears with the form data all right, but its menu, header, and footer--all server-side includes--are missing. Those includes work fine with all other pages on the site.
In the acknowledgment page I've tweaked the includes' paths many ways (full path, relative to page, relative to site root, etc.) but no joy. I'm suspecting maybe the include code itself (<!--#include virtual="path/to/my/footer.shtml" --> is an example) doesn't work with formmail.php.
I'm using the formmail.php good_template feature to direct the browser to the acknowledgment page. My form has the line <input type="hidden" name="good_template" value="acknowledgment.shtml" />
Is there some special coding I need to do to have includes work on a good_template page?
wardw
10-09-2009, 11:53 AM
I discovered the problem, and now my acknowledgement page looks fine.
In my formmail.php I had $TEMPLATEDIR pointing to the directory where my acknowledgement page was. But my acknowledgement page is an .shtml page, not a .php page, so I needed to leave $TEMPLATEDIR empty and specify $TEMPLATEURL instead, like
$TEMPLATEURL = "http://mysite.com/acknowledgementdirectory";
That worked. The paths to my include files had been correct in the first place (relative); the error was in my formmail.php file.
wardw
10-15-2009, 03:28 PM
Uh oh. I thought my problems were solved, but they're not. When my form has action="acknowledgment_page.shtml", the acknowledgment page displays the server-side includes and all the form data just fine. But of course, no email is sent.
When the form has action="formmail.php", email is sent with all the form data, but in my acknowledgment page no form data appears. The page's PHP code works fine, all except for the code that's supposed to receive and display the form data.
Anyone have any idea why pointing to the formmail.php page appears to prevent form data from being passed to my acknowledgment page?
felgall
10-15-2009, 06:56 PM
Is the acknowledgement page trying to read from the posted values directly? If so then that will not work as they only get passed that way to the first script. For the form2mail to pass them to the following page it needs to create a session and copy the post fields into corresponding session fields. The following page can then use the same session and read the values from there.
wardw
10-16-2009, 04:31 PM
Thanks, fellgall; it make sense that the form data would be lost before reaching the acknowledgment page.
To fix this I've set up a PHP session, but still no form data is being passed to the acknowledgment page.
My form, formmail, and acknowledgment pages all begin with
<?php session_start(); ?>
On my formmail.php page I have
$_SESSION ["email"] = $email;
to create a session variable called email and to set email = the form variable $email.
On my formmail page, I tried both
echo "Your email address is ".$email.".";
and
echo "Your email address is $email";
But in either case the acknowledgment page shows only "Your email address is".
If on the formmail page I put <?php echo $_POST["email"]; ?> the form's email value displays fine, so the value gets at least that far. But if I put that string on the acknowledgement page the value is not displayed.
Have I made a simple syntax error, or am I going about this the wrong way?
felgall
10-16-2009, 07:00 PM
Thanks, fellgall; it make sense that the form data would be lost before reaching the acknowledgment page.
To fix this I've set up a PHP session, but still no form data is being passed to the acknowledgment page.
My form, formmail, and acknowledgment pages all begin with
<?php session_start(); ?>
On my formmail.php page I have
$_SESSION ["email"] = $email;
to create a session variable called email and to set email = the form variable $email.
On my formmail page, I tried both
echo "Your email address is ".$email.".";
and
echo "Your email address is $email";
But in either case the acknowledgment page shows only "Your email address is".
If on the formmail page I put <?php echo $_POST["email"]; ?> the form's email value displays fine, so the value gets at least that far. But if I put that string on the acknowledgement page the value is not displayed.
Have I made a simple syntax error, or am I going about this the wrong way?
That would need to be
$_SESSION ["email"] = $_POST['email'];
inorder to copy the field (unless you already copied it from there into $email).
and then in the destination page you need the same start session line at the top and
echo "Your email address is ".$_SESSION['email'].".";
wardw
10-17-2009, 04:28 PM
Thanks again, felgall; I tried your suggestion but the values still weren't passed to the acknowledgment page. I finally found a workaround, though; I cheated by adding the code from the formmail.php page to the acknowledgment page, so the form data doesn't have to be passed from the form to formmail.php and then to the acknowledgement page.
The form action is now "acknowledgement_page.shtml", which contains all the formmail code, so the data is passed to the acknowledgement page just fine, and formmail's email message is also sent with all the data.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.