mafkeesxxx Posted September 4, 2006 Share Posted September 4, 2006 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 More sharing options...
AndyB Posted September 4, 2006 Share Posted September 4, 2006 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 More sharing options...
mafkeesxxx Posted September 4, 2006 Author Share Posted September 4, 2006 [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]<font color='ff0000'>Thanks for your mail.</font>[/b]Any Ideas? :-) Link to comment https://forums.phpfreaks.com/topic/19666-php-and-html/#findComment-85701 Share on other sites More sharing options...
wildteen88 Posted September 4, 2006 Share Posted September 4, 2006 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. Link to comment https://forums.phpfreaks.com/topic/19666-php-and-html/#findComment-85706 Share on other sites More sharing options...
mafkeesxxx Posted September 4, 2006 Author Share Posted September 4, 2006 [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] functionThanks ! Link to comment https://forums.phpfreaks.com/topic/19666-php-and-html/#findComment-85713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.