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

$_GET problem
Hi all,

Have a bit of a problem with a little piece of code, I am not sure if this should be

SCO Unix
I know this might not be the place to ask, but, can anyone tell me if SCO Unix comes with PHP built

update the selected existing records of database
Hi frndz,
I am new to php and get stuck....

Edit.php > Update.php > Updatea

PHP5 - AJAX help
I've been following the tutorial on w2schools (http://www.w3schools.com/php/php_ajax_database.asp) a

Sequre login with cookies.
I want to build secure login with cookies. I just want your ideas about this, your suggestions. What

error reporting
hey everyone

I have a production server in which I want error reporting but only on some page

Making multiple rows with one query
I have a table called efed_handler_characters with two fields handler_id and bio_id. What query 2 is

Multiple Options for a Single Page
For this example I want to use the Handlers option which is under Fed Admin and all the related codi

ALV sum various columns problem
Hi all,
I'm doing a report on ABAP for a timesheet of the current month. The output i want is s

unexpected T_VARIABLE error
Hey all! I'm getting an unexpected T_VARIABLE with the following function:

function getHighes

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