richrock Posted January 9, 2009 Share Posted January 9, 2009 Hi all, Although this is about formmail (the script), it's really about the implementation of a particular piece of code relating to it. In the form, I have this: <input type="hidden" name="recipient" value="emailaddress@domain.com" /> which defines who receives the forms posted to formmail. This is fine, but the presence of a complete email address has caused a sharp rise in spam being received So, for most "<a href="mailto...."'s I use this little piece of javascript: <script language="JavaScript" type="text/javascript"> <!-- var name = "emailaddress"; var domain = "domain.com"; document.write('<a href=\"mailto:' + name + '@' + domain + '?subject=Enquiries\">'); document.write(name + '@' + domain + '</a>'); // --> </script> And generally it works. But even with my html experience, I'm probably being a complete dummy and can't figure how to merge the two together. I guess I'm looking for something like: <input type="hidden" name="recipient" value="<script language="JavaScript" type="text/javascript"> <!-- var name = "emailaddress"; var domain = "domain.com"; document.write('<a href=\"mailto:' + name + '@' + domain + '?subject=Enquiries\">'); document.write(name + '@' + domain + '</a>'); // --> </script>" /> But it doens't work... Any ideas, or alternatives to hiding email addresses? TIA Rich Quote Link to comment https://forums.phpfreaks.com/topic/140138-obfuscating-email-addresses-in-formmail/ Share on other sites More sharing options...
rhodesa Posted January 9, 2009 Share Posted January 9, 2009 you really should have the email address as a hidden input, as someone can modify that value and use your script to spam people. instead, define the 'recipient' in the php of the formmail script (i'm pretty sure there is a place already defined) Quote Link to comment https://forums.phpfreaks.com/topic/140138-obfuscating-email-addresses-in-formmail/#findComment-733443 Share on other sites More sharing options...
richrock Posted January 9, 2009 Author Share Posted January 9, 2009 Yeah there is a place in the formmail script - it just refers the POST data in this case, the hidden referrer as the email address. I'm looking at a way of stopping this email address being either a: visible in the source code, or b: using a code which can be used to refer to the email address on the server... hang on, I think that may be it. I think I'll mark this solved, I'll just need a while to knock up a php script to convert a garbage hidden input into an email address, without it appearing in the source code. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/140138-obfuscating-email-addresses-in-formmail/#findComment-733466 Share on other sites More sharing options...
rhodesa Posted January 9, 2009 Share Posted January 9, 2009 if there is only one page using the formmail script, just define the email address in the formmail script. if you have multiple pages using the same formmail script, just make a hidden field on each form (call it ref or something) and put it like so: <input type="hidden" name="ref" value="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" /> then at the top of your formmail script, have a switch statement that assigns the correct variables: switch($_POST['ref']){ case '/path/to/page1.php': $recipient = 'someone@host.com'; break; case '/path/to/page2.php': $recipient = 'someoneelse@host.com'; break; default: die("Unknown post"); } Quote Link to comment https://forums.phpfreaks.com/topic/140138-obfuscating-email-addresses-in-formmail/#findComment-733474 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.