开发者

Using PHP to avoid meaningless text in form fields

开发者 https://www.devze.com 2023-03-20 01:48 出处:网络
I tried to make php form script, which process data submitted by the user, but I want to find, how can I allow only meaning full text in those form fieldslike \"Honey\" and other real meaning full use

I tried to make php form script, which process data submitted by the user, but I want to find, how can I allow only meaning full text in those form fields like "Honey" and other real meaning full user names

I mean, sometimes, user may enter its name like: assalhdjsdyoeorsdhs. although text entered is within allowed text length, but its not a name at all, so how to disallow such non-sense usern开发者_开发问答ames, which created for just to submit an entry like in comments page also.


From a list of existing usernames, create a Markov chain on the likelyhood of the next letter. E.g. when you encounter the letter D, it is likely that the next letter is an E but it is nog likely that is is an M.

Then, check each new username against this Markov chain to determine the likelyhood that it is a normal username.

Using PHP to avoid meaningless text in form fields


I think the only sure way of doing this is to have human intervention in the approval process for new users.

I don't know if that's an option for you, but a software based system is sure to be more trouble than just ignoring the problem.

I had a similar problem on a bulletin board I run, in the end I appointed some trusted users as admins and all new users had to be authorised manually. The problem was solved, but we don't have a high number of new users.

Edit

Another option I have just thought of is to use one of the methods suggested here to flag a user name for human attention.


you have to create database which will keep the relevant names.from where you can check every entry.it is not possible to prevent users for submitting words like "agasdffdssd"


You could download a plain-text dictionary, and then check if the registered name is in that dictionary. Here is a sample website with dictionaries, including the English one: http://www.winedt.org/Dict/


You must first define what you consider "meaningful". Is "Demla" meaningful? It might not be in the dictionary (at least not in the Dutch one :) ), so you can't use that. You could parse for certain word-shapes, but you would have to take all the false positives or false negatives for granted. It won't be 100% at all. Is Asd a name? or the beginning of ASDF?

You could start something with a Markov chain, but you'd have a hard time getting it right and also explaining this to your users on false positives...

I'd filter problematic entries on other fields, and dissallow some basic stuff (like letters).


http://www.haykranen.nl/2008/09/21/markov/ may this useful. it has markov generator with some source to download. try it.

0

精彩评论

暂无评论...
验证码 换一张
取 消