email link not working

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • starman
    New Member
    • Sep 2006
    • 15

    email link not working

    Hi - hopefully this is a simple question, just HTML / PHP.
    I have a php script that retrieves (among others) bare email addresses from a DB table (i.e., just in the form ' whatever.thing@ example.com') which are then displayed on a webpage. I would like these to be clickable links, so have the relevant line as:
    Code:
    echo "<b>Email: </b><a href='mailto:>" .$themail. "</a><br>";
    Everything echoes properly, with the email address clickable. As a test, I retrieved my own email address.
    However...when I mouseover this link, all that appears in the status bar is "mailto:" without an address. And clicking on the link sends the mail from me rather than to me!
    Last edited by Atli; Feb 18 '10, 03:48 PM. Reason: Please use @example.com for example emails. Random domains tend to actually exist :)
  • zorgi
    Recognized Expert Contributor
    • Mar 2008
    • 431

    #2
    Code:
    echo "<b>Email: </b><a href='mailto: ".$themail."'>" .$themail. "</a><br>";

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Or better yet:
      Code:
      echo "<b>Email: </b><a href='mailto: $themail'>$themail</a><br>";
      No point breaking out of a double-quoted string to add variables.

      Comment

      • zorgi
        Recognized Expert Contributor
        • Mar 2008
        • 431

        #4
        Thanks for pointing that out Atli. Just a bad habit of mine since the times when I only used dreamweaver. Dreamweaver doesn't highlight variables within the string so variables look like string and are very hard to spot. Eclipse does much better job :)

        Comment

        • starman
          New Member
          • Sep 2006
          • 15

          #5
          thanks you two! Worked first time, and I was also able to adapt the code so that web addresses were linked properly too.
          Many thanks.

          Comment

          Working...