Adding HTML into PhP?

  • Thread starter Thread starter Memphis
  • Start date Start date
M

Memphis

Guest
Hi,

I have added the <strong></strong> tags to a few sections of my PhP script so that the output email I receive makes it easier to differentiate between the question and the answer.

Here is the bit of PhP code:

<strong>Name:</strong> * *" .$name ."\n"
."\n<strong>Telephone:</strong>**" .$telephone ."\n"
."\n<strong>Email:<strong>**" .$email_from ."\n"
."\n<strong>How did you hear about us?:</strong>**" .$hear ."\n\n"
."\n<strong>How would you like us to contact you?:</strong>** Via" .$contact ."\n"
."\n<strong>Customer's Message:</strong>**" ."\n\n" .$comments;

When I test my form, it works, however only the first two, Name and Telephone are bold. The rest are bold but are making the answer bold too.

How can I make it so that only "Name:, Telephone:, Email; How did you hear about us:" are bold but not the answer the user gives?

Why are the first two (name and telephone) working properly but the rest aren't?

Thanks very much

(Newbie to PhP)
LoL!

I'm such a nabcake.

Thanks you guys :P
 
When you add strings like these there is a great chance to get them wrong. If you take a look on the email line, you will see that you haven't closed the <strong> tag.
Use the complex string format to help you with placing the variables inside a string and it will make it simpler to work (since you can use only one string with everything or just like bellow).
Example:
$emailBody = "<strong>Name:</strong>{$name}";
$emailBody .= "<strong>Telephone:</strong>{$telephone}";
$emailBody .= "<strong>Email:</strong>{$email}";
$emailBody .= "<strong>How did you hear about us:</strong>{$hear}";
$emailBody .= "<strong>How would you like to contact you:</strong>{$contact}";
$emailBody .= "<strong>Message:</strong>{$message}";

P.S. Unless you are building an email and really need HTML be outputted from PHP, avoid echoing HTML or setting it to a variable. Just make's the code harder to read.

I got a ton of resources on the blog bellow.

Have fun.
 
<strong>Name:</strong> " .$name ."\n"
."\n<strong>Telephone:</strong> " .$telephone ."\n"
."\n<strong>Email:<?strong> " .$email_from ."\n"
."\n<strong>How did you hear about us?:</strong> " .$hear ."\n\n"
."\n<strong>How would you like us to contact you?:</strong> Via" .$contact ."\n"
."\n<strong>Customer's Message:</strong> " ."\n\n" .$comments;


I think just the slash after Email:<? is what you need to add - where I have put a question mark.
 
It's just because you've not closed the tag around "Email:", you have:

<strong>Email:<strong>

and what you want is:

<strong>Email:</strong>
 
"\n<strong>Email:<strong> " .$email_from ."\n"

You're missing a '/' somewhere... not going to tell you where, because im an evil bastard :P

btw... I didn't even know strong was still used :o( I thought that was decripitated years ago! :o\
 
Back
Top