My name is Ken Cooper. This is my last question. Well, I have a form on my site. It inserts stuff into that database, and it selects it from the database. The page is - http://www.coopercentral.org/opinions.phpWell if I type something in, and submit it, I use PHP_SELF, and it displays the stuff. Well, right after I press submit, it displays the stuff, and if I press refresh, the same exact stuff submits it into the database. I use the ($empty) and the NULL and it still does it. Can anyone help me. Thanks a lot, I really appreciate it!!

When you've submitted a form, the page you are viewing is specific to the data you've submitted. It's not a standard page. Therefore, when you're refreshing it, in an attempt to get the same page up your browser is resubmitting the information!

There are two ways around this. Change the action of your page to a different page, and use this page to send you back to the form page and display the results (much like this forum works). In this way when you refresh the page you're not submitting variables again.

Or you could get your database to check whether or not the data has already been entered, and if not then it'll enter it.

Kenneth wrote:Jay, thanks! How would I do the second one you said? I like my pages using PHP_SELF all in one. Thanks

Ken Cooper

Me too.

Do your records have certain ID numbers? Or certain characteristics that separate them? Worst come to worse just check if each field matches what you're about to insert. All you want to do is count how many rows match the data you're about to insert, if you find none then it's new so go ahead. If you find a row, then chances are it's been inserted and you don't insert. Simple

Thanks a lot Jay, I really appreciate. But believe it or not, I'm only 14, and I'm a kid that is just learning PHP. If its not too much trouble, could you possibly make up some code so I could see an example. Like I was talking about the Average thing before, I got code for example. Yes, I do have id's to seperate themselves. Thanks a lot, I really appreciate it.

Kenneth wrote:Thanks a lot Jay, I really appreciate. But believe it or not, I'm only 14, and I'm a kid that is just learning PHP. If its not too much trouble, could you possibly make up some code so I could see an example. Like I was talking about the Average thing before, I got code for example. Yes, I do have id's to seperate themselves. Thanks a lot, I really appreciate it.

Thanks a lot Jay, I really appreciate it. I shall try that. What I'm going to do is, well, I don't want to echo any message, I just want it to show nothing, just the HTML form. On my opinions page, if nothing is submitted, then it just shows the form, if something is submitted, it shows the results in the table. Thanks a lot, I really appreciate it!!!

Sorry, I tried it, and it still entered the same data. Is there any other way? Well one more thing, if its not to much to ask, if its still possible, when you do an if else statement, doesn't echo a message, because I just want it to show the form both ways. Is there a way? Thanks a lot, I really appreciate it!!

Kenneth wrote:Sorry, I tried it, and it still entered the same data. Is there any other way? Well one more thing, if its not to much to ask, if its still possible, when you do an if else statement, doesn't echo a message, because I just want it to show the form both ways. Is there a way? Thanks a lot, I really appreciate it!!

Ken Cooper

Your query checking whether or not the values have been inserted before is obviously flawed then. Check it carefully (and logically).

If you want to show the form both ways, leave the form outside the if statement (after it preferably).

I'm sorry Jay, I still couldn't get it to work. I don't know whats wrong. I did the entire code, and it inserted well, its just that when I refresh, the SAME THING keeps going in. I really don't know how it still does. I guess it's just not possible then, I don't know. But you don't have to take up your time to do this. Thanks a lot for your help, I really appreciate it!!!

1. the form (post data to part 2)
2. - the query wich enters the data into the page
- some text saying "data entered in database"
- a link to part 3 of you're file
3. display the list (the part you're refreshing)

how to do this??
could be something like this:
a variable called "subpage", if it's not set, display the form. if it is "post" proces the form and add the data into the database. and if the variable is "display" display you're list.

Alright thanks. Well, I don't really want this topic to get to be huge. Here's what I'm going to do. I'm going to give you the address of the page I want, and the code + tables I use. Experiment with it, and tell me an answer, if you come up with one. I really appreciate it!!!

Thats the code. PLease. like I said, just go to the page above, I show you, and just type in something. I have a weekly opinion, and just type something in. It shows, the press refresh, it shows the same thing. I don't want that. My friend told me to use the $variable=NULL; to empty out the variables, but that didn't work here. Can you find a solution? If you want, and if you have time, using a Personal Web server, just test that script, and find something that will make it not show it twice. Like I said, if someone types something in or not, I don't want to display any message. Thanks a lot, I really appreciate it!!!

I like the first one, where I count. Sorry, but could you possibly just give me an example? Don't go way out of your way, but your awesome at this stuff. Could you just give me a little example, I know what you mean, just general code of that. Thanks a lot, I really appreciate it!!

Kenneth wrote:I like the first one, where I count. Sorry, but could you possibly just give me an example? Don't go way out of your way, but your awesome at this stuff. Could you just give me a little example, I know what you mean, just general code of that. Thanks a lot, I really appreciate it!!

Ken Cooper

I did give you an example, read between the bold tags!! That'll return how many rows contain that value, and you only need to insert your comment if it resolves to 0!