Jump to content


Photo

PHP and HTML


  • Please log in to reply
4 replies to this topic

#1 mafkeesxxx

mafkeesxxx
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 04 September 2006 - 12:58 PM

Hi,

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

$sThanksmail = "Thanks for you mail.";

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:

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

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

Thanks in advance.

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 04 September 2006 - 01:00 PM

careful with the " character so the php interpreter doesn't get confused about where a string ends.  You can either do it like this:

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

or this:

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

Legend has it that reading the manual never killed anyone.
My site

#3 mafkeesxxx

mafkeesxxx
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 04 September 2006 - 01:08 PM

careful with the " character so the php interpreter doesn't get confused about where a string ends.  You can either do it like this:

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

or this:

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


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

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

When i look in de source:

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

Any Ideas? :-)

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 04 September 2006 - 01:22 PM

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.

#5 mafkeesxxx

mafkeesxxx
  • Members
  • PipPip
  • Member
  • 12 posts

Posted 04 September 2006 - 01:43 PM

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.


GREAT !!!

It works! I deleted the htmlspecialchars function

Thanks !




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users