contact form - output to page and email


Posted on 16th Feb 2014 07:03 pm by admin

I have the following in my controller:

$message['name'] = htmlentities(strip_tags(trim($_POST['name'])));

$message['email'] = htmlentities(strip_tags(trim($_POST['email'])));

$to = "info@mywebsite.com";
$subject = "Website Enquiry";
$content = html_entity_decode(implode("nn", $message));
$content.= "nnIP Address: ".$_SERVER['REMOTE_ADDR'];
$headers = "From: ".strip_tags(trim($_POST['name']))." <".strip_tags(trim($_POST['email'])).">";
@mail($to,$subject,$content,$headers);


And the following in my view:

echo '<tr><th><b>Name: </b></th><td>'.$message['name'].'</td></tr>';

echo '<tr><th><b>Email Address: </b></th><td>'.$message['email'].'</td></tr>';


This works as expected - the POST data is output to the page and is also sent in the email. However the email does not contain the field labels, for example 'Name: ' and 'Email Address: '.

This is obviously because I don't include the labels in their respective $message[] elements, as I need to enclose these in HTML tags in the view. I don't intend to include any HTML code in my controller, so does anyone have any idea how I can satisfy both requirements?

No comments posted yet

Your Answer:

Login to answer
197 Like 20 Dislike
Previous forums Next forums
Other forums

Force download script not handling files with spaces properly
I have a regular old php force download script, uses this code:

Code: header("Cache-Cont

value not going in data base
hello friends....
i am having a working javascript....when i am selecting any

Server side $_SESSION
how does one keep the session completely server side. no cookies to the browser at all. i need this

how to make database item unique
Hey guys,

is it possible to do this:

I have the database item $title being pulled for

Running a cron job through PHP/Apache?!
Hello all,
I have a PHP script which makes a cron file from user input. When i try to run the cro

Simple Question
I know this is a simple question, that if I knew what it was technically called i could probably loo

gmmktime or mktime
I live in the UK, i am within the GMT (with daylight saving time ie 1 hour difrence between summer a

Having problemswith multithreading and prime numbers
I have an assignment when I'm suppose to do the following:

Write a multithreaded Java, Pt

WM transfer order: confirm different batch than proposed by system
Hi folks,

following scenario: we have a full WM with mixed batch numbers allowed in stora

Empty text file when there is over XXXX lines of text.

define("RANDOM_FILE","/public_html/random.txt");
$randomEntry = "

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash