View Full Version : Form Action when included into another page.
Im including a form (form.php) into another page (mainpage.html) using SSI (Server Side Includes) but when i try to submit the form, i get an error: "INTERNALLY GENERATED file-relative req"
The form action is
action="<?php echo $_SERVER['PHP_SELF'] ?>"
How can i get this to work, without leaving the Mainpage.html???
Thanks for you help, its greatly appreciated.
bluewalrus
08-26-2010, 08:31 PM
Try closing the echo with a semi-colon.
action="<?php echo $_SERVER['PHP_SELF']; ?>"
If that doesn't resolve it that's not where the error is coming from and all your code will be needed.
Well, as you know, $_SERVER['PHP_SELF'] is the filename of the currently executing script, relative to the document root, which means that it should use the current page link to process the, form in this case. Now, the problem is that the form it self is being included using SSI into an html page, now my question is how can i work around this without leaving the html page, or at least not completely.
Hope you get my question...
bluewalrus
08-26-2010, 11:13 PM
Oh, so your looking for how to parse the .html extension as a php page correct? You should look at mod rewrites. You could also direct the page to another php page and use a header to redirect the user back to the html page.
You also should close that echo though for proper syntax.
Thank, i think that is the best way to do it, but how can i get it to display the error message on the html page instead of the php file where the direction is being made to?
prasanthmj
08-27-2010, 03:00 AM
how can i get it to display the error message on the html page
Use the 'target' attribute to send the response to an <iframe>
See some examples here:
How to create a multi-submit form (http://www.html-form-guide.com/blog/web-form/91/submit-form-multiple-scripts/)
djr33
08-27-2010, 04:08 PM
You can also use .htaccess (and perhaps other methods) to set the .html extension as a "php" extension, so that all .html files are parsed like .php files. Since PHP allows for html pages (even pages without any php code), this will not change anything except that it will make all .html pages a little slower to load, but probably not enough that it will be a problem. If you have a VERY busy site, it might make the performance lower, but that is something to be dealt with later, probably.
However, in general I strongly suggest avoiding .html as php because it's confusing and there is almost always a better way. SSI? Why not just use include() in PHP?
bluewalrus
08-27-2010, 04:13 PM
If there is an error redirect them to an error page a get request that tells the error.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.