Results 1 to 8 of 8

Thread: Form Action when included into another page.

  1. #1
    Join Date
    Apr 2007
    Posts
    149
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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
    PHP Code:
    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.

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    Try closing the echo with a semi-colon.

    PHP Code:
      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.
    Corrections to my coding/thoughts welcome.

  3. #3
    Join Date
    Apr 2007
    Posts
    149
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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...

  4. #4
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    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.
    Corrections to my coding/thoughts welcome.

  5. #5
    Join Date
    Apr 2007
    Posts
    149
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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?

  6. #6
    Join Date
    Nov 2008
    Posts
    58
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Default

    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

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    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?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    If there is an error redirect them to an error page a get request that tells the error.
    Corrections to my coding/thoughts welcome.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •