Jump to content

PHP and HTML


mafkeesxxx

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.
Link to comment
https://forums.phpfreaks.com/topic/19666-php-and-html/
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]
Link to comment
https://forums.phpfreaks.com/topic/19666-php-and-html/#findComment-85698
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? :-)
Link to comment
https://forums.phpfreaks.com/topic/19666-php-and-html/#findComment-85701
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 !
Link to comment
https://forums.phpfreaks.com/topic/19666-php-and-html/#findComment-85713
Share on other sites

Archived

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

×
×
  • Create New...

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.