0

I created plugin and my plugin create new Table in DB. My problem is when user type something in field firstname, lastname... and click on button Submit, that go to my table and that is ok.. but then when user do a refresh page, then again i get the same imports in my table. And if field are empty and I do refresh I get the new row in table with empty firstname and lastname.. Here is my code..

http://pastebin.com/RJcFXeUV - this is my main.php

http://pastebin.com/Myqz5brq - this is mu form.php

So I want to enter data in my table just when fields are !empty and only when user click the submit, not after every refresh..

3
  • Please don't use pastebin or other services, if those links ever stop working, this question becomes useless to future users. In addition, this is a generic php question and would be better served on stack overflow proper because it simply happens in the context of WordPress. The quick answer to your question though is that you're running the insert no matter what. Nov 24, 2014 at 21:07
  • I just checked a few of your other questions, it looks like you're getting started with coding, at least php, and WordPress. Congrats! Stick with it, I know it's frustrating. No matter how good you get though, you're always going to run into times where you don't understand why things aren't working. I'm totally for asking for help, but trying to work through these things on your own will teach you how to break problems into smaller, solvable pieces, and teach you debugging skills. Getting answers that you can copy/paste doesn't help anyone. Nov 24, 2014 at 21:10
  • Thank you for answer :) I'm trying to do it all but now I stopped and I do not have any idea. To the last questions I did not get an answer but I'm find a solution. I hope that someone can help me here.. I think that i have everything just need to make right place for all that :) Nov 24, 2014 at 21:21

1 Answer 1

0

Simple – if you do not want duplicate information then before you insert anything check if such data is already present. Just query for it and see if there is a match.

From WP perspective however, you seem to be looking at technique (database table) that you will rarely need in practice. WordPress offers wealth of storage options and your time is likely better spent exploring theme, before rolling your own custom storage.

1
  • Thank you for answer.. I think i find my problem.. My problem is thsi form : <form name="cool_form" method="post" action="<?php echo str_replace( '%7E', '~', $_SERVER['REQUEST_URI']); ?>"> ... </form> What to put in action ..:/ Nov 24, 2014 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.