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

article site help remaining text
Hi all hope you will be fine
I am creating a article site in this site i want to put some text on

Is it possible to stop reservation creation in PM Order?
Hi All,

Is it possible to stop reservation creation in PM Order?

Thanks in adv

trouble printing an array....
I'm having some trouble printing out an array forwards. I'm figuring out the high and low of an arra

PHP FTP Can't upload Big FIles
Anyone had any success using FTP to upload a file say 90m?

im using ftp_put and it returns fa

Inserting Data into a MS Access DB using PHP.
As part of my uni course I am doing a placement at a company whom want me to create a client zone fo

Calling strings from other php class
I have test1.php{
$string1;
$string2;
....
... //10 strings in this class <

turning an array into a string then poping it into a db
Hi im just wondering how you get a requested array into a single string then pop it into the db so f

Transform value 0 in no and 1 in yes help needed
Hello,
I have this in the table: "value" type int 0 to represent false and 1 to represe

scandir clients directory
hi,
how can i scandir the clients directory? i need a script that when i click a button it will u

Convert .fdf to .pdf
I currently have a web form that uploads the form data to an .fdf file and emails it.

However

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