A few days ago, my blog was flooded with spam comments, dozens of them. I have never experienced such a situation since I have been building a website for so long. I blame myself for not adding a verification code function. In order to prevent being attacked again, it is necessary to have a verification code filtering program. I searched for some information on the Internet and felt that it was always uncomfortable to use code written by others. I couldn't write complicated code myself, especially the kind that generates pictures. I have tried many methods on the Internet but nothing works. I don’t know why, maybe I don’t have experience. It feels quite complicated.
In the end, I spent an hour writing a super simple verification code. Haha, it is absolutely original. It only has a dozen lines of code. It is randomly generated. Because it is relatively simple, it cannot deal with those powerful posting software, but it is better than nothing. After putting the verification code, I have observed it for more than a few days and no spam has been seen. It should be effective, haha.
example:
======show.asp======
Copy the code code as follows:
<%
randomize
randm=Int((9000*rnd)+1000) randomly generates a 4-digit numeric code
%>
Verification code: <INPUT name=yzm id=netadd size=4 maxlength=4> <%=randm%> Here is a text box, and the randomly generated function is called next to it
This js code is to verify whether the entered verification code is correct.
Copy the code code as follows:
<SCRIPT type=text/javascript>
function sendForm(obj)
{
if(obj.yzm.value!=<%=randm%>)
{
alert(verification code error);
obj.content.focus();
return false;
}
obj.submit();
return true;
}
</SCRIPT>
Add this sentence to the OK button
<INPUT onclick=sendForm(this.form); type=button name=Submit2 value=Add>
The red text must be read clearly. If it does not correspond, it will not work.
It's basically that simple. It can be said to be the core code. In fact, it can be made more complex, but I haven't thought about it yet. I will do it when there are no more spam posts.