I see what you mean. I suggest making a separate page to process the form... such as formprocess.php. When the user is sent to the page, you can access all the variables using $_GET or $_POST arrays (depending on how your form is sent), add the new record, and then at the bottom send the user back to the original page. You can also send variables back with the user via a query string, although this does have security implications
Stephen ----- Original Message ----- From: "Max Graham" <[EMAIL PROTECTED]> To: "Rich Gray" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Thursday, November 28, 2002 3:18 PM Subject: Re: [PHP-WIN] Redirect browser to another URL? > The original issue was, I tried to have the single page to display any > previous comments, and then a form to add comments. Then, once it was > submitted, it would submit itself. The page was supposed to detect whether > any new data had been submitted, by way of a hidden input in the form, and > if so, would first write to the output file and then display the output > file. It wasn't a text file in this case, it was actually an HTML snippet I > would get the script to grab with the include() function. What I had to do, > because I suspected there wasn't enough of a delay between > writing/flushing/closing the file and including it (maybe it thought the > include file was still locked from being written to), was split the file > into two separate files. The first comments page shows the past comments and > the submission form. The form submits to a separate file that writes to the > include file and then displays the only displayed code in the page. In the > header I have a refresh function, and in the body tag I have the onload > handler set to trigger the refresh function. > > I just realized, though, the setTimeout may be redundant ... :P I'm still > managing to learn slowly ... like most things I do, it's all self-taught, > and you're right -- I haven't even touched SQL databases. My only > familiarity with databases was with FoxPro before it became "Visual FoxPro" > (ominous music here). And I haven't even toyed with turning off Javascript > ... there are services I'll turn off, but javascript ... for all its > resemblance to C++ with bipolarism, I have been tempted to turn it off, but > it just somehow reminds me of that scene from the Indiana Jones movie where > he's trying to weigh how much sand in the bag will equal the weight of the > statue to avoid triggering the booby traps ... > > ----- Original Message ----- > From: "Rich Gray" <[EMAIL PROTECTED]> > To: "Max Graham" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> > Sent: Thursday, November 28, 2002 3:05 AM > Subject: RE: [PHP-WIN] Redirect browser to another URL? > > > > Hi Max > > > > Well it seems you are messing around with text files rather than a > > database - this sounds like hard work :) I'm not sure I fully understand > > your issue but are you saying you could not make the code 'refresh' the > > comments data on the form page without a javascript redirect? > > > > What happens if you switch off javascript in your browser - does it fail? > > > > Rich > > -----Original Message----- > > From: Max Graham [mailto:[EMAIL PROTECTED]] > > Sent: 28 November 2002 05:51 > > To: [EMAIL PROTECTED] > > Subject: Re: [PHP-WIN] Redirect browser to another URL? > > > > > > You know, this is exactly what happened to me. I was trying to design a > > comments page for a weblog to open in a popup. The page had a submission > > form that would submit back to itself. 'course, I was banging my head on > the > > wall trying to come up with a way to get the page to detect whether it had > > received a form submission and write the comments to a comment file, and > > then include the comment file with the form afterwards. I kept coming up > > with the results of fopen(), fputs(), fflush(), and fclose() coming back > as > > false, which equals failed. I eventually did go to a separate page to do > the > > file writing, and that page finishes up with a 1-second delay using the > > javascript setTimeout() for this command in a standalone function: > > > > echo "location.replace('blogcomments.php?target=".$target."');\n"; > > > > Inelegant, but it works. I haven't had too much experience with the header > > function, and knowing how long it took me to bang this one out, I might > set > > something on fire trying it :) > > > > Anyone else had any fun with this issue? > > > > > > > > > > > -- > PHP Windows Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php