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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.