Re: Problems with PHP3 script - Missing Post reply data
| From: | Mike Gifford | Date: | Fri, 30 Jun 2000 01:25:59 +0000 |
| Subject: | Re: Problems with PHP3 script - Missing Post reply data | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-3935@lists.php.net to get a copy of this message | ||
Hi Michael,
Just to let you know, I fixed the problem by changing the form to GET
rather than POST the data.
Michael Dearman wrote:
> > I've got a simple html form which is posted to a php3 file. The PHP
> > file is processing it and it looks to be mostly correct.
> You mean your actually getting an html page rendered when you hit the submit
> button?
> (cont'd)
On the screen I was getting the page I wanted. When I viewed the source
however, I just got the text that I specified in the initial email.
> > <TITLE>Missing Post reply data</TITLE>
> > <H1>Data Missing</H1>
> > This document resulted from a POST operation and has expired from the
> > cache.
> Check how your browsers cache is set up?
It was set to 0
> You know, this brings something up. I've read that (I guess) by default)
> (at least) Apache sends the result request to the browser in such a fashion
> that dynamically generated pages won't be cached. You have to do some magic
> with expires module or some such. Or does PHP handle this?
No idea... I'd be interested in knowing though. As this page is
sitting on an Apache server.
> The below FORM and SCRIPT are embedded in proper html elements?
Yes they were.
> > <?php
> > $cardfile="cardfile.txt";
> > $dataarray=file("$cardfile");
> > $filearray = file("$cardfile");
> Just curious: Why 2 arrays of some thing? Apparently not using $filearray.
I was modifying an existing script & wasn't sure if it was required. I
will remove one of them though. Thanks.
> > $httpcounter=0;
> > $tok = strtok($dataarray[$viewcard-1],":");
> Oh, should of mentioned "Tain't a guru". But, $viewcard coming in as a number
> that is a string? Don't know, just that the input type is text. Well, if a single
> digit, type casting not a problem. But you might want to do some validation here or
> just force a type cast to int. Or maybe not.
It should always be a number. It should be the number of lines of the
cardfile.txt+1 I believe. How do I make it so that it doesn't accept
"A" or other invalid strings in the form?
> > while($tok){
> > $httpcounter++;
> > if ($httpcounter == 1) {
> > echo "";
> > } elseif($httpcounter == 2){
> > echo "<table><tr><td><IMG
> > STYLE=\"$tok\"></td> ";
> > } elseif ($httpcounter == 4) {
> > echo "<td><table><tr><td> TheMessage: $tok
> > </td>";
> > } elseif ($httpcounter == 5) {
> > echo "<td> Sender: $tok </td>";
> > } elseif ($httpcounter == 6) {
> > echo "<td> SEmail: $tok </td>";
> > } elseif ($httpcounter == 7) {
> > echo "<td> Reciever: $tok </td>";
> > } else {
> counter hits 3, falls thru to here. Isn't this screwing your
> table up?
Yup, Indeed it was. I'll attach the revised script to the bottom.
THE NEW (WORKING) FORM:
<form method="GET" action="receive.php3">
<input type="text" size="5" name="viewcard">
<input TYPE="SUBMIT" VALUE="View Card!"></form>
THE NEW (WORKING) SCRIPT:
<?php
$cardfile="cardfile.txt";
$dataarray=file("$cardfile");
$httpcounter=0;
$tok = strtok($dataarray[$viewcard-1],":");
while($tok){
if ($httpcounter == 0) {
echo "";
} elseif($httpcounter == 1){
echo "<table BORDER=0 WIDTH=\"100%\">\n<tr>\n<td ALIGN=CENTER
VALIGN=TOP>\n<IMG src=\"graphics/$tok\">\n</td>\n ";
} elseif ($httpcounter == 2) {
echo "<td VALIGN=TOP>\n<table BORDER=0 CELLSPACING=0 CELLPADDING=0
COLS=2
WIDTH=\"100%\">\n<tr>\n<td>\n<b>To:</b>\n</td>\n<td>\n<a
href=\"mailto:$tok\">";
} elseif ($httpcounter == 3) {
echo "$tok</a>\n</td>\n</tr>\n";
} elseif ($httpcounter == 4) {
echo "<tr>\n<td>\n<b>From:</b></td>\n<td>\n<a
href=\"mailto:$tok\">";
} elseif ($httpcounter == 5) {
echo "$tok</a>\n</td>\n</tr>\n</table>\n";
} elseif ($httpcounter == 6) {
echo
"<B>Message:</B><BR>$tok</td>\n</td>\n</tr>\n</table>\n";
} else {
}
$tok = strtok(":");
$httpcounter++;
}
?>
--
Mike A. Gifford OpenConcept Consulting
Mike@OpenConcept.On.Ca Http://www.OpenConcept.On.Ca
Web Design, Hosting, Graphic Design & Site Promotion
Featured Site --> Http://WTOAction.Org