2 Replies - 286 Views - Last Post: 12 March 2012 - 07:34 PM Rate Topic: -----

#1 mikelash  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 94
  • Joined: 17-June 11

adding links to text

Posted 12 March 2012 - 06:44 PM

i have a mail page on my site and im looking to make it so if anyone adds a link in there mail they send that it is a clickable link on the other end how would i do this?

while($nt = mysql_fetch_array($rt)){//adds all the values to the table
	$sent_mail .= "<tr>";
	$sent_mail .= "<td>".$nt['recipient']."</td>\n";
	$sent_mail .= "<td>".$nt['subject']."  </td>\n";
	$sent_mail .= "<td>".$nt['sent_time']."</td>\n";
	$sent_mail .= "<td>".$nt['message']."  </td>\n";
	$sent_mail .= "</tr>";
}



Is This A Good Question/Topic? 0
  • +

Replies To: adding links to text

#2 e_i_pi  Icon User is offline

  • = -1
  • member icon

Reputation: 795
  • View blog
  • Posts: 1,681
  • Joined: 30-January 09

Re: adding links to text

Posted 12 March 2012 - 07:23 PM

You can just use an anchor:
<a href="mailto:youremailaddress">Email Me</a> 


Was This Post Helpful? 1
  • +
  • -

#3 SirHenrik  Icon User is offline

  • New D.I.C Head

Reputation: 17
  • View blog
  • Posts: 31
  • Joined: 31-December 10

Re: adding links to text

Posted 12 March 2012 - 07:34 PM

So as I understand your post you want the links in
$nt['message']
to be clickable.
I am not to sure if your talking about sending emails, or internal messages in your own application. But if your talking about emails then bear in mind that you have send them in HTML, and not plain-text if you want clickable links supported.

You will want to run a replace function on your
$nt['message']
and possibly
$nt['subject']


This function should do the trick.

function makeClickableLinks($text) { 

  $text = eregi_replace('(((f|ht){1}tp://)[-a-zA-Z0-9@:%_\+.~#?&//=]+)', 
    '<a href="\\1">\\1</a>', $text); 
  $text = eregi_replace('([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&//=]+)', 
    '\\1<a href="http://\\2">\\2</a>', $text); 
  $text = eregi_replace('([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})', 
    '<a href="mailto:\\1">\\1</a>', $text); 
   
return $text; 
}



Just going to note right away that I found this function on totallyphp.co.uk..
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1