Re: php form and ssi



Henrik Carlqvist wrote:
"Álvaro G. Vicario" <alvaroNOSPAMTHANKS@xxxxxxxxxxxxxx> wrote:
If I recall correctly, the "include virtual" directive in SSI generates
a new request to the web server

Thanks for your reply! Yes, that is correct, new requests are generated. I
have made an .shtml page which includes a file phpinfo.php and find the
following in the log files of apache:

"GET /~henca/test/form_test.shtml HTTP/1.1" 200 36308 "-" "Mozilla/5.0...

"GET /~henca/test/phpinfo.php?=PHPE9568F34-D428-11d2-A769-00AA001ACF42
HTTP/1.1" 200 2974 "http://localhost/~henca/test/form_test.shtml";
"Mozilla/5.0...

So first the .shtml file is loaded, then the included php file is loaded.

A few interesting things to note:

1) A string "?=PHPE95..." has been added to the php url, this was not
included in my .shtml file.


Looks like it was added by mod_include. I haven't checked into why this might occur.

2) Even though it is the apache web server that transparently loads the
.php file the log says that it was my browser Mozilla... that requested
the file.


That's how mod_include works - it generates another request to Apache to load the included module.

3) The .shtml file is given as the referer on the log line for the .php
file.


That is correct.

so, as far as PHP is concerned, the_form.php is an independent script
and both $_SERVER["PHP_SELF"] and $_SERVER["REQUEST_URI"] refer to it.

You could really expect that would be the case, but in my test with
phpinfo() I can see that $_SERVER["REQUEST_URI"] points to the .shtml
file.


Correct, because it is the .shtml file which is performing the request.

Perhaps this works but, of course, it has nothing to do with PHP:

<!--#include virtual="the_form.php?foo=bar"-->

Yes, that would work to pass variables from .shtml to .php. Unfortunately
it would hardcode the variable names as well as their values so this
solution wouldn't be usable to pass any data given by a user in a form.

Whatever, in HTML an empty action attribute defaults to current page:

<form method="post" action="">

Thanks for the tip. Unfortunately with action="" I get the same result as
with action=\"$_SERVER["REQUEST_URI"]\", that is I get an error message
saying:

405 Method Not Allowed
The requested method POST is not allowed for the URL /form_test.shtml.


Correct, because Apache doesn't think a .shtml file can process POST information.

Is it possible to pass form data to a php script through an .shtml
file? I would prefer a solution where the .shtml file doesn't need to
have any knowledge about the data it passes to the php file.
I can't understand why you can't simply get rid of SSI but I suppose
you'll have your reasons.

In my case my reason is phpoi, available at http://phpoi.sourceforge.net/
. Phpoi consists of a number of php scripts. Their html output doesn't
look much to the world, but the php scripts are meant to be used by
different people who can include them from .shtml pages with other
contents and designs.


I see one file (download.shtml) which references using shtml files. And I'm not sure I agree with that. Plus, this is a new project, and hasn't had much for uses yet

Most of the time you include php files from other php files, not shtml files.

Today it all works great except for the administration php scripts which
uses forms and once the forms are used they have to escape from any
.shtml-page with an action=\"$_SERVER["PHP_SELF"]\".


You need to follow up with this on the phpoi support forums. It's their scripts, they should know how to make it work.

However, now I would like to also add forms to the pages used by normal
users. As I don't know who will use phpoi and what
their pages look like I don't want the php code to output all the
formatting stuff.


Why not? Someone has to output formatting stuff.

regards Henrik


--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.



Relevant Pages

  • Re: php form and ssi
    ... At first I was unable to post through .shtml and therefore I asked my ... the .shtml page when I used virtualon apache. ... php form went as expected to the php file given as action. ... As a developer of an opensource project more customers would not mean more ...
    (comp.lang.php)
  • Re: php form and ssi
    ... Normally, you would use a php file to include your phpoi files, not a shtml file. ... like I don't want the php code to output all the formatting stuff. ...
    (comp.lang.php)
  • Re: php form and ssi
    ... a new request to the web server ... So first the .shtml file is loaded, then the included php file is loaded. ... Even though it is the apache web server that transparently loads the ...
    (comp.lang.php)
  • Re: php form and ssi
    ... But I am looking for a way for the .shtml file to pass the POST ... information to an included .php file which is able to do the processing. ... I wish that I was only a simple phpoi user which could ask for help in the ... If they today have built their site with menus and formatting ...
    (comp.lang.php)
  • Re: Trying to get a web page with Winsock
    ... was what I had in my request already. ... assigned the sample line out of RFC2616 to the request string. ... Private sHTML As String ... Private Sub Winsock1_Connect ...
    (microsoft.public.vb.controls)