Click to See Complete Forum and Search --> : Calling HREF from PHP


tobyw_1969
07-12-2003, 04:36 AM
I'm really struggling with the syntax for how to do this.

I want to e-mail a message which includes a hyperlink, and displays a piece of text for the link, instead of the link itself. I am trying to do it like this




mail($emailto, "Subject", <a ref='http://www.myurl.com'>"Please click this link"</a>);






I just can't work out how I am supposed to do the syntax for this. Do I need an echo statement first? Can anyone help me out?


Thanks

Toby

brendandonhue
07-12-2003, 07:26 PM
$message = "<a ref='http://www.myurl.com'>Please click this link</a> ";
mail($emailto, "Subject", $message)

tobyw_1969
07-13-2003, 04:17 AM
Thanks but that doesn't work. That's why I was posting.

My code looks like this at the moment:


$mailmessage="<a href="http://www.myurl.com>Link</a>";

echo $mailmessage;

mailto(emailaddress, "Subject", $message);



What this outputs in the browser is a hyperlink saying 'Link', but in the email, it outputs

<a href="http:// ...... etc


So is this to do with mail settings? I can receive other HTML e-mails fine, so is there something in PHP I need to do to tel the mail recipient that this is an HTML message?

Thanks

Kr|Z
07-13-2003, 07:05 AM
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$message = "<a href="http://www.myurl.com>Link</a>";

mail($to, $subject, $message, $headers)

Bootsman123
07-13-2003, 01:49 PM
Originally posted by Kr|Z
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

$message = "<a href="http://www.myurl.com>Link</a>";

mail($to, $subject, $message, $headers)

It should be this:


$message = '<a href="http://www.myurl.com">Link</a>';

or

$message = "<a href=\"http://www.myurl.com\">Link</a>";

tobyw_1969
07-13-2003, 05:14 PM
Thanks for your answers but I still can't get it to work. The point is that I am trying to combine text and the URL in the message, so that is says some stuff as well as giving the link - and that's where I am having trouble ... I tried to add those things, but it's still outputting the <a href> part as text..

This is my exact code now:


$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


$mailmessage = 'You have received a new greetings card from {$namefrom}. To view your greetings card please click on this link <a href="http://www.netcartoon.net/greetings/showmessage.php?messagenum={$messagenum}">Your greetings card</a>';

mail($emailto, "New greetings card from {$_POST["namefrom"]}", $mailmessage, "From:{$emailfrom}", $headers);


echo $mailmessage;




This is sending a mail like this....






You have received a new greetings card from {$namefrom}. To view your greetings card please click on this link <a href="http://www.netcartoon.net/greetings/showmessage.php?messagenum={$messagenum}">Your greetings card</a>




But the echo statement outputs this in the browser window..


You have received a new greetings card from Toby. To view your greetings card please click on this link. Your greetings card.






Where am I going wrong? This is driving me mad...

brendandonhue
07-13-2003, 07:30 PM
Your email server/client probably doesn't allow HTML mail

tobyw_1969
07-14-2003, 09:14 AM
Thanks all who replied.

I found the problem - it was in the actual mail() command - was trying to pass in two header parameters. It works now :)

Jonathan
07-14-2003, 11:51 AM
I am new to all of this PHP stuff, can someone explain why headers and headers . are different? and, what does this do? an href?


$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";


$mailmessage = 'You have received a new greetings card from {$namefrom}. To view your greetings card please click on this link <a href="http://www.netcartoon.net/greetings/showmessage.php?messagenum={$messagenum}">Your greetings card</a>';

mail($emailto, "New greetings card from {$_POST["namefrom"]}", $mailmessage, "From:{$emailfrom}", $headers);


echo $mailmessage;

brendandonhue
07-14-2003, 11:58 AM
.= is an operator to append to a string.
So the new variable headers, equals the old value of headers, plus Content-type: text/html; charset=iso-8859-1\r\n

Jellybean
12-15-2004, 11:13 AM
Hi,

I am doing something like the email system. Right now, I need to send an html email with a hyperlink.

All goes well, except that the hyperlink address in the emails (during my trial runs) show this:

http://mail.yahoo.com/config/login?/ \"http:www.example.com\"

Upon clicking this link, the portion in red will always prompt for the yahoo! login in id and password, instead of directing the reader to the link http:www.example.com

May I know how can I get rid of the unnecessary red portion? :confused:

My code is:

$message="<a href=\"http://www.example.com/example.html\"><i>Example Website</i></a>";

Any advise is most appreciated.

Thanks for reading.

Regards,
Jellybean
:D

Jellybean
12-15-2004, 11:15 AM
Hi,

I am doing something like the email system. Right now, I need to send an html email with a hyperlink.

All goes well, except that the hyperlink address in the emails (during my trial runs) show this:

http://mail.yahoo.com/config/login?/ \"http://www.example.com\"

Upon clicking this link, the portion in red will always prompt for the yahoo! login in id and password, instead of directing the reader to the link http://www.example.com

May I know how can I get rid of the unnecessary red portion? :confused:

My code is:

$message="<a href=\"http://www.example.com/example.html\"><i>Example Website</i></a>";

Any advise is most appreciated.

Thanks for reading.

Regards,
Jellybean
:D

bokeh
01-24-2005, 09:32 AM
Should be this:
$message='<a href="http://www.example.com/example.html"><i>Example Website</i></a>';