Hi.
Uh... I sincerely apologize if this is the wrong board - I tried and tried and tried and tried and....ok you get it.... to find a code snippet that 'encodes' and 'decrypts' email addresses.
I would have thought in this day and age you could find any piece of code in about 12 seconds........but not so.

The idea is that you first encode an email address that you will use in a mailer script from a contact form. You store the encoded string so that bots can't easily pickup your email addresss. Then in the mailer script you would call this piece of code to 'decrypt' the characters into the email addresss, so that the address is only present in memory.

Sorry if there's something famous out there that I don't know about.... but I looked for a 1/2 hour yesterday with no luck

Codeless in Columbus

    You don't need to find a script. You can write this in 3 seconds.

    Your form should look like this:

    <form action="page2.php" method=post>
    Name: <input type=text name="first_name"><br>
    City: <input type=text name="city">
    <input type=hidden name="destination_email_address" value="43">
    <input type=submit value="Send Us Mail">
    </form>
    

    So, as you can see from the form, you are embedding an encrypted email address. It's "43". So in the PHP script, you need to decrypt that like this:

    <?php
    $email = $_POST['destination_email_address'];
    
    if ($email==1) { $to_email = "bob@smith.com"; }
    if ($email==2) { $to_email = "sally@smuthers.com"; }
    if ($email==3) { $to_email = "jean@aol.com"; }
    if ($email==43) { $to_email = "steve@msn.com"; }
    
    // Then just execute the mail command to send mail to the decrypted 
    // email address which is in the variable $to_email
    ?>
    

    This is far more secure than MD5 or any other encryption that you can find. Why? Because "2" simply cannot be reversed to figure out that the recipient was
    sally@smuthers.com.

      Well there is a so-called javascript solution out there that does this, but it is client-side and is no good in fighting smart bots. If I find it, I will pass it on, maybe it would have something in there that will spark a php solution?

        By the way, this technique is sufficient for situations where you need to "encrypt" about 10 emails or less. If you need 10-50, you should probably use an array. And if you need more than 50, then I'd use a database.

          Write a Reply...