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'])));
Did you know?Explore Trending and Topic pages for more stories like this.
$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
20
Other forums
HOW to get the bind variables list.
I've the following problem : I've some SQL queries stored in my DB as VARCHAR2 values.
I need t
Simple Question
I know this is a simple question, that if I knew what it was technically called i could probably loo
Chat Box in PHP
I was thinking in doing a Chat Box in PHP. For that I would use a form with two fields, Nick and Mes
PHP Script runs on CLI but not through web browser
I am running into an issue that I just can't seem to find the answer to. I have a Windows Server 200
Problem with DB connection
Hello there! I'm new to this forum and I'm new to PHP coding also. I wrote something that doesn't ma
Unable to retreve the values from Mysql Query
Hi,
Here is the php code that I have, Query is running properly in phpmyadmin and is resu
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
Generate PDF
Hi guys,
I would like to know if there is a way to generate pdf when clicking on a link. In f
Multiple upload and Resize
I would like some help on my script I have the for my index.php
////
<html&
help with database debug pls
Parse error: syntax error, unexpected T_ELSE in /home/content/m/e/s/mesick/html/students/05/php/chec