Jump to content

Archived

This topic is now archived and is closed to further replies.

mafkeesxxx

PHP and HTML

Recommended Posts

Hi,

I'm a total newbee here. My question is. How can i combine PHP and HTML in a mailform.
I have this code:

[b]$sThanksmail = "Thanks for you mail.";[/b]

Now everything works fine, but i would like to put some HTML in the mail the user will recieve, something like a color.
But if i try this:

[b]$sThanksmail = "<font color="ff0000">Thanks for you mail.</font>";[/b]

It doens't work. Can anyone tell me what i have to do to make this work?

Thanks in advance.

Share this post


Link to post
Share on other sites
careful with the " character so the php interpreter doesn't get confused about where a string ends.  You can either do it like this:

[code]$sThanksmail = "<font color='ff0000'>Thanks for you mail.</font>";[/code]

or this:

[code]$sThanksmail = "<font color=\"ff0000\">Thanks for you mail.</font>";[/code]

Share this post


Link to post
Share on other sites
[quote author=AndyB link=topic=106839.msg427711#msg427711 date=1157374858]
careful with the " character so the php interpreter doesn't get confused about where a string ends.  You can either do it like this:

[code]$sThanksmail = "<font color='ff0000'>Thanks for your mail.</font>";[/code]

or this:

[code]$sThanksmail = "<font color=\"ff0000\">Thanks for your mail.</font>";[/code]
[/quote]

Ok, thank you very much, now i recieve an e-mail with:

[b]<font color='ff0000'>Thanks for your mail.</font> [/b]

When i look in de source:

[b]&lt;font color='ff0000'&gt;Thanks for your mail.&lt;/font&gt;[/b]

Any Ideas? :-)

Share this post


Link to post
Share on other sites
Looks like you pass the $sThanksmail  variable through htmlentities/htmlspecialchars function. Or your own function which converts any html chars into their html entity equivalent.

Share this post


Link to post
Share on other sites
[quote author=wildteen88 link=topic=106839.msg427719#msg427719 date=1157376173]
Looks like you pass the $sThanksmail  variable through htmlentities/htmlspecialchars function. Or your own function which converts any html chars into their html entity equivalent.
[/quote]

GREAT !!!

It works! I deleted the [b]htmlspecialchars[/b] function

Thanks !

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.