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?

197 Like 20 Dislike
Previous php-forum Next php-forum
Other php-forum

Insert data in Mysql and move to another page
I'm stuck with this simple problem. I need to insert data in Mysql and then hit submit and move to a

Display a default image
I am trying to display generic image for items that don't have one, but I can't get it to display.

list files from folder, only one for each date
I have many files in a folder and wish to only list one of each date

these are the file names

why does my session end?
my connect.php starts the session just so you know
i can navigate arround my site fine except whe

php problem?
I don't think I'm stupid, but maybe I am.

I am working on a sit for a friend I am try to put

Extending Exception to contain method name
I was wondering, if there's a way to extend Exception in such a way, that it would contain name of a

Multiple WHILE loops help
Hi there. I'm writing an application that is pulling and displaying results for real estate listing

Echo multiple lines of html code
Hi guys,

I would like to know if there is a way to echo multiple lines of html codes.

add text and number image
hi guys ..

ok see i want the user to add their name and pick a number then click get it and i

ctype() validation - allowing illegal characters
Hello,
I use ctype() to filter and validate a user form. However, I am trying to allow certain c

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