<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Allan Mwaura</title>
    <description>The latest articles on DEV Community by Allan Mwaura (@allanmwaura).</description>
    <link>https://dev.to/allanmwaura</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F473515%2Fa9f35fb4-5f26-45cc-a725-c248bc62c955.jpg</url>
      <title>DEV Community: Allan Mwaura</title>
      <link>https://dev.to/allanmwaura</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/allanmwaura"/>
    <language>en</language>
    <item>
      <title>How to prevent web forms from spam</title>
      <dc:creator>Allan Mwaura</dc:creator>
      <pubDate>Tue, 25 May 2021 14:22:07 +0000</pubDate>
      <link>https://dev.to/allanmwaura/how-to-prevent-web-forms-from-spam-2p4p</link>
      <guid>https://dev.to/allanmwaura/how-to-prevent-web-forms-from-spam-2p4p</guid>
      <description>&lt;p&gt;In the world of today,as a website/blog owner,you tend to receive tons of emails/comments from bots.Different prevention techniques have been taken,this article aims will cover honeypot method.&lt;/p&gt;

&lt;p&gt;The honeypot method uses a hidden field on forms,as a trap for "less intelligent" bots who will automatically fill the form.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form action="mail.php" method="POST"&amp;gt;
&amp;lt;p&amp;gt;
    &amp;lt;label&amp;gt;Name&amp;lt;/label&amp;gt;
    &amp;lt;input type="text" name="first_name"&amp;gt;
&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;
    &amp;lt;label&amp;gt;Email&amp;lt;/label&amp;gt;
    &amp;lt;input type="email" name="email"&amp;gt;
&amp;lt;/p&amp;gt;
&amp;lt;p id="phone"&amp;gt;
    &amp;lt;label&amp;gt;Tel&amp;lt;/label&amp;gt;
    &amp;lt;input type="text" name="phone_number"&amp;gt;
&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;
    &amp;lt;label&amp;gt;Comment&amp;lt;/label&amp;gt;
    &amp;lt;textarea name="your_comment"&amp;gt;&amp;lt;/textarea&amp;gt;
&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;
    &amp;lt;button type="submit"&amp;gt;Submit&amp;lt;/button&amp;gt;
&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We then hide the field using CSS,so that visitors(assuming they are human) won't see it.On your CSS file add the following line&lt;/p&gt;

&lt;p&gt;#phone{display: none;}&lt;/p&gt;

&lt;p&gt;So here is where the catch is,any submission with not empty phone field,is spam.&lt;/p&gt;

&lt;p&gt;if(!empty($_POST['phone_number']))&lt;br&gt;
 die();&lt;/p&gt;

&lt;p&gt;Thanks for reading!!.&lt;/p&gt;

</description>
      <category>spam</category>
    </item>
  </channel>
</rss>
