Closed Thread Icon

Topic awaiting preservation: another question (sorry) . . . Pages that link to <a href="https://ozoneasylum.com/backlink?for=12738" title="Pages that link to Topic awaiting preservation: another question (sorry) . . ." rel="nofollow" >Topic awaiting preservation: another question (sorry) . . .\

 
Author Thread
CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-14-2003 19:58

Still working with the same PHP script, this time I have something different about it though.

It posts the message fine (thanks Bit for the code). However, when I hit Refresh, it posts the last posting twice. Not sure why that is, maybe it is because I am running it on my home computer using phpDev ??? Not sure.

Thanks in advance.

Later,

C:\


~Binary is best~

DL-44
Maniac (V) Inmate

From: under the bed
Insane since: Feb 2000

posted posted 05-14-2003 23:45

Basically when you hit refresh it is resending the variables, so it enters the info again.

As far as how to stop it?

I've been wondering that too =)

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-15-2003 00:00

There's a couple of techniques for this. One is to use a cookie to prevent reposting within a small amount of time.

Another is to post to one page that creates the file but doesn't display anything. After the code to create the file redirect the page to your display page that shows all the posts (this will not kill the back button however).

For your script however there is a better way. Instead of creating the date stamp in your page that creates the file, create the datestamp in the form and pass it as a hidden field.

<input type=hidden name=datestamp value=<?= $date; ?>>

Something like that. Then in your code which creates the file look for another file with that name. If it already exists then don't rewrite the file.



.:[ Never resist a perfect moment ]:.

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-15-2003 03:08

ah, the ol' hidden field trick That sounds good. But can I still save the file with the date stamp? I guess that is what you are saying to do with the hidden field. Maybe not, it's late and I am running on V E R Y little sleep.

The reason I was wanting to save the file with the date stamp name is so I can go back and add a "comment" link. Now what I mean? Kind of like posting something and then let people add there comments. Yeah that silly thing.

What I am trying to do is write a PHP flat file blogger. I know, there are a million free ones out there for the taking so why re-create the wheel. Well. . , good learning experience.

Bad thing is, I have to keep coming here and bugging you guys to help me along the way. But, that is what a great board like this is for.

Thanks for the help.

Later,

C:\


~Binary is best~

bitdamaged
Maniac (V) Mad Scientist

From: 100101010011 <-- right about here
Insane since: Mar 2000

posted posted 05-15-2003 18:03

Oh absolutely, the trick here is just creating the timestamp earlier. What you do is every time someone goes to the "form" page you create the timestamp there, then pass the timestamp to the page which processes the form (I think it's "posts.php"). This way you should have a single unique identifier for each visit to the form that you can use to make sure there is only one submission per form use.

Now on posts.php don't create a new timestamp, use the one passed by the form and before creating the new text file read the contents of the directory for a file with that timestamp. If it already exists then don't recreate it. If it doesn't exist then create the flat file the same way you were earlier (again with the timestamp passed by the form).

Is this making sense?




.:[ Never resist a perfect moment ]:.

CPrompt
Maniac (V) Inmate

From: there...no..there.....
Insane since: May 2001

posted posted 05-15-2003 19:30

Yes, it makes sense. I thought I was reading (and understanding) what you were saying. So I just pass the variable from the form to the posts.php page. Then in the posts.php page, before I actually create the file, I check to make sure that it is NOT there. If it is not then I create it, if it is there, don't create it.

Gotcha! That sounds like something I can do

This will make it easier too when I go back and add a "Comment" for the individual posts too. This way I can just grab the timestamp for the individual posts and pass the variable that way. Or am I doing that wrong. Have to do some testing.

Thanks for the "direction". I am wanting to really do as much of this on my own without someone writing it for me. Good learning

Thanks again!

Later,

C:\


~Binary is best~

« BackwardsOnwards »

Show Forum Drop Down Menu