SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Get email to code so that I get no spam?

    I found this website
    http://www.rubiconproductions.com/co...ast.net&number=
    where you can put in your email address
    test@test.com
    and it gives you code to put into your <a href>, when I put test@test.com it gives me the following
    Code:
    &# 116 ;&# 101 ;&# 115 ;&# 116 ;&# 064 ;&# 116 ;&# 101 ;&# 115 ;&# 116 ;&# 046 ;&# 099 ;&# 111 ;&# 109 ;
    and I just put it into my html like so
    Code:
    <a href="<A href="mailto:test@test.com">Contact">mailto:test@test.com">Contact Me</a>
    I'm trying to figure out if there's a way to get php to do this automatically. I have a list of email addresses in a database and I would like to echo them out in this html format. Is there a way to do that? Here's my code:
    Code:
    $MailLink="<a href='mailto:".$Row["EmailAddress"]."'>E-Mail<BR>".$Row["FullName"]."</a>";
    Any help is appreciated!
    Last edited by DKY; Jul 7, 2007 at 09:24.

  2. #2
    SitePoint Evangelist optl's Avatar
    Join Date
    Oct 2004
    Location
    Washington DC
    Posts
    415
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What I would do is make an array of letters and have each letter's key be the html equivalent of the letter. Then just loop through the array.
    For the phrase "Bethesda home architect", my clients
    websites occupy 6 of the first 8 results
    on the 1st page of Google. My Secret SEO Strategy Revealed

  3. #3
    SitePoint Member
    Join Date
    May 2007
    Location
    Canada
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that code you posted before are just html entities.... put &# in front of any numbers from 97-122 to get lower case letters and 48-57 for numbers 1-9 and so on...ill whip something up and post it.

  4. #4
    SitePoint Addict
    Join Date
    Aug 2003
    Location
    IL
    Posts
    292
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This works!
    Code:
    $email = "test@test.com"; $encoded = ""; for ($i=0; $i < strlen($email); $i++) { $encoded .= "&#" . ord( substr( $email,$i ) ); }
    Thanks!

  5. #5
    SitePoint Evangelist
    Join Date
    Aug 2005
    Posts
    453
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function txt2ascii($str){
        
    $len strlen(trim($str));
        
    $new_str '';
        for(
    $i=0$i<$len$i++){
            
    $new_str .= '&#'.ord($str{$i}).';';
        }
        return 
    $new_str;

    Computers and Fire ...
    In the hands of the inexperienced or uneducated,
    the results can be disastrous.
    While the professional can tame, master even conquer.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •