Tuesday, 15 May 2012

php - Maintain breaks, new rule in contact form's textarea? -



php - Maintain breaks, new rule in contact form's textarea? -

i building contact form , wondering if there possibility maintain line breaks text-area, e-mails styled html nicer in email program.

i read articles nl2br command i'm not sure place code since not php freak.

here's code:

<?php $name = $_post['name']; $email = $_post['email']; $message = $_post['message']; $from = 'from: info@epicconcepts.nl'; $to = 'info@epicconcepts.nl'; $subject = 'contact formulier bericht'; $human = $_post['human']; $headers = "from: info@epicconcepts.nl\r\n"; $headers .= "reply-to: ". strip_tags($_post['email']) . "\r\n"; $headers .= "cc: quincynorbert@gmail.com\r\n"; $headers .= 'mime-version: 1.0' . "\r\n"; $headers .= 'content-type: text/html; charset=iso-8859-1' . "\r\n"; $body = '<!doctype html> <html> <head> <style type="text/css"> body{background: #231f20; width:670px; height:100%;} #header-mail{background:#110f10; width:650px; height:70px;} #content{background:#231f20; width:630px; height:100%; padding: 20px; word-wrap:break-word;} .mail-text{font-family:arial; color:#fff; font-size:10pt; line-height:130%;} .bold{font-family:arial; color:#fff; font-size:10pt; font-weight:bold;} </style> </head> <body> <img src="http://test.epicconcepts.nl/images/bg-mailer.png" alt="website alter request" /> <div id="content"><p class="bold">'.$name.'<br><br>'.$email.'</p><p class="mail-text"> '.$message.'</p> </div> <a href="http://www.epicconcepts.nl"> <img src="http://test.epicconcepts.nl/images/mailer-footer.png" alt="website alter request" /> </a> </body> </html>'; if ($_post['submit']) { if ($name != '' && $email != '') { if ($human == '4') { if (mail ($to, $subject, $body, $headers)) { echo '<p class="correct-message">your message has been sent!</p>'; } else { echo '<p class="correct-message">something went wrong, go , seek again!</p>'; } } else if ($_post['submit'] && $human != '4') { echo '<p class="correct-message">you answered anti-spam question incorrectly!</p>'; } } else { echo '<p class="correct-message">you need fill in required fields!</p>'; } } ?> <form method="post" action="contact.php"> <label>naam</label> <input name="name" placeholder="type hier"> <label>email</label> <input name="email" type="email" placeholder="type hier"> <label>bericht</label> <textarea name="message" placeholder="type hier"></textarea> <label>hoeveel 2+2?</label> <input name="human" placeholder="type hier"> <input id="submit" name="submit" type="submit" value="verzend"> </form>

you wrap $body nl2br this:

if (mail ($to, $subject, nl2br($body), $headers)) {

php html

No comments:

Post a Comment