Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6764661
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:37:12+00:00 2026-05-26T14:37:12+00:00

Is there anyway of detecting a duplicate form submit with PHP? I have a

  • 0

Is there anyway of detecting a duplicate form submit with PHP?

I have a textfield which is used for typing a one-word phrase into it (eg. “Google”). When the user presses the submit button, the form containing that textfield gets submitted.
After that – on the PHP processing page – some data gets selected from a database. If the submitted word doesn’t exist, it gets inserted in to the db. But if it already exists, the existing one gets a vote up. This might be a little complicated, but I think it is understandable.

The only problem is that when a user submits something like this: “Google.” it gets submitted, although there is already a record that contains “Google”.

My question is simple:
How can I check for duplicates?

[I already tried out the mysql function: LIKE, but it didn’t really work, because when someone submitted something like this: “Goofy” it contained “Goo” in it which is already in the word “Google” -> which is already inserted. ]

So how could I solve this? Is there any good script for it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T14:37:13+00:00Added an answer on May 26, 2026 at 2:37 pm

    While I agree with @Dustin about using the INSERT ... ON DUPLICATE KEY UPDATE you may want to address this issue at the user input level with javascript or PHP during submission rather than having the SQL try and match the strings.

    What are the restrictions of the input field currently. Would you expect users to be using punctuation, number, and other general non-alpha characters?

    example of non-alpha: 1234567890-=()!@#$%^&*_+,./<>?;':"|\
    

    If this is the case I would you a preg_replace or a regExp to remove any of these unwanted characters. Thus removing the problem at is sources.

    Once you have validated/cleansed the input you can use a simple SQL insert like so:

    INSERT INTO table (string, count) VALUES (1,2)
       ON DUPLICATE KEY UPDATE count=count+1;
    

    Hope that helps a little.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there anyway to have a sort of virtual static member in C++? For
Is there anyway to have items in an ASP.NET DropDownList have either their Text
Is there anyway in XAML only to have a linebreak in a TextBox? I
Is there any way in PHP of detecting the following character � ? I'm
I have a form that disables submit button, when it is clicked. But what
Is there anyway to configure a WCF service with a failover endpoint if the
Is there anyway in Java to delete data (e.g., a variable value, object) and
Is there anyway to upgrade the installed JRE in the system? We are having
Is there anyway to declare an object of a class before the class is
Is there anyway to combine all resources into a single exe file such as

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.