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
Staff Induction System - No idea where to go from here!!!
Hi there, I'm pretty new to PHP and Mysql so could really do with being pointed in the right directi
Target costs on Process orders not calculating
Hi All,
We have released standard costs for all the materials. We have also done Goods r
php multiple action on submit
I have a form which says:
<form enctype='multipart/form-data' method='post' action='pr
Escaped characters
I have a script that allows you to post news to the home page of my site. Along with the news is the
Coding question?
Hey guys, I have a quick question. If I want to make a way for people to pay for health in my game,
Check something, wait, check again, do something!
Hi guys.
I wonder if someone can help me with this.
Basically, what I want to do is (
Anti Spam Code
Ok where do i start? Probably by telling you I have very little working knowledge of PHP and that I
Storing Values taken from a DB...
Using this code it will generate a short list from my database
<?php
mysql_connect
close site for maintenance
i get a tutorial, saying the following code can put our site offline, and only the developer can vie
have trouble in a if condition
The if below is working ok, it check when indexes, name, zipcode and state are empty.
Code: &