February 12, 200917 yr Hi guys, I'm working on a website at the mo on which I need to include a contact email address using a Contact Me button. I know there are ways of hiding the address from spam bots using Java but wondered if theres any way using php. I've quickly written this: <?php $mc="@tiscali."; $ma="pat"; $md="net"; $mb=".james"; echo ' <p class="emph3"><a onmouseover="window.status=\'mail\'; return true;" onmouseout="window.status=\' \'; return true;" href="mailto:' . $ma . '' . $mb . '' . $mc . '' . $md . '">Contact Me</a> </p>'; ?> but, as I suspected before I'd written it, the full email address still appears on the site when you do "view source" and so I assume that spam bots will be able to see it. Does anyone have any suggestions? Many thanks Rob
February 12, 200917 yr Try: <?php function hideEmail($strText) { $strNew = ""; for ($i = 0; $i < strlen($strText); $i++) { $strNew .= "" . ord(substr($strText, $i, 1)) . ";"; } return $strNew; } ?> Then: <a href="<?php echo hideEmail('mailto:name@domain.com')?>">Contact me</a> Try it - it puts everything into nn notation.
February 12, 200917 yr Author Try: <?php function hideEmail($strText) { $strNew = ""; for ($i = 0; $i < strlen($strText); $i++) { $strNew .= "" . ord(substr($strText, $i, 1)) . ";"; } return $strNew; } ?> Then: <a href="<?php echo hideEmail('mailto:name@domain.com')?>">Contact me</a> Try it - it puts everything into nn notation. Thanks ZigPress. That seems to do the trick - at least until the spam bots catch onto the nn notation
February 13, 200917 yr I put mailto emails like below: <script type="text/javascript"> document.write("thisis"); document.write("myemail"); document.write("@hot"); document.write("mail.co"); document.write("m"); </script>
February 13, 200917 yr What happens if the user has JavaScript disabled? They go to the contact page and fill out the contact form, lets face it 80% of sites are heavily JS based now, a lot of companies are slowly phasing out the "what if javascript is disabled" motto
February 14, 200917 yr Just playing devil's advocate I agree that people are probably resigning themselves to the JS requirement, especially with things like Gmail taking over the world. You should still probably see how a screen reader handles it though, especially if it's for a commercial site...
February 14, 200917 yr i personally use skidz method, and then if js is disabled it links to the contact form. Very few people other than bots seem to have js disabled. And if they have js disabled, they can just fill out the form, easy peasy.
Create an account or sign in to comment