Re: Re: including in shtml
| From: | Tom Rogers | Date: | Sat, 22 Feb 2003 03:46:13 +0000 |
| Subject: | Re: Re: including in shtml | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-136590@lists.php.net to get a copy of this message | ||
Hi,
Saturday, February 22, 2003, 12:29:36 PM, you wrote:
HP> Im trying to write a poll script that is easy to intergrate into other
HP> documents of a site and thought that since shtml is a much used method, I
HP> want to make it available.
HP> "Hans Prins" <HPrins@xgn.nu> schreef in bericht
HP> news:20030221134243.36183.qmail@pb1.pair.com...
>> Hello,
>>
>> I have a problem with including a "test.php" into a "test.shtml" and
HP> passing
>> a variable to the "test.shtml" which should be processed in the
>> "test.php"
>>
>> the "test.php" document includes the following:
>> -----------------------------------------------------------
>>
>> <?php
>>
>> if ($HTTP_GET_VARS['theValue']) {
>> print $HTTP_GET_VARS['theValue'];
>> } else {
>> print"
>> <form method=\"GET\" action=\"test.shtml\">
>> <input type=\"text\" name=\"theValue\" size=\"20\">
>> <input type=\"submit\" value=\"Submit\"
>> name=\"submit_button\">
>> </form>
>> ";
>> }
>>
>> ?>
>>
>> the "test.shtml" document includes the following:
>> -------------------------------------------------------------
>>
>> <html>
>> <head>
>> <title>poll</title>
>> </head>
>> <body>
>> <!--#include virtual="test.php" -->
>> </body>
>> </html>
>>
>> I've also tried using the POST method but I got an error stating that post
>> is not a valid method in shtml.
>>
>> I have also considered a session variable but since a session needs to
>> initiated or continued before anything is output to the browser that wont
>> work (I think).
>>
>> does anyone have a solution to get this to work?
>>
>> thanks,
>> Hans
>>
>>
POST won't work easily with .shtml files so you are limited to GET and its
length limitations but the following works for me:
//test.php
<?php
if(isset($_SERVER['QUERY_STRING_UNESCAPED'])){
parse_str($_SERVER['QUERY_STRING_UNESCAPED']);
if(!empty($theValue)){
echo 'Value = '.stripslashes($theValue).'<br>';
}
}
print'
<form method="get" action="test.shtml">
<input type="text" name="theValue" size="20">
<input type="submit" value="Submit" name="submit_button">
</form>
';
?>
(parse string seems to like adding slashes)
To use post you will have to post to a .php file to do the processing and
redirect to the .shtml file.
--
regards,
Tom