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
email CODING Problem
Email coding problem.
I need to send a section of the info to $tf and the same as a Cc to $em
login page does not execute a else statement
I've created a login page using sessions.
When an incorrect user name or password is entered then
Php WordPress help
I am writing the following code for making a plugin
<?php
header("Content-Type
Send inserts to mysql thru port 80
Hi!
I have an application that must do some inserts in a mysql db. This db is behind a firewa
quotes changing
hi all
in my content
opening quotes " changes to “
close qu
re calling a function without including file
Hi,
i am new to programming in php, i was just checking the wordpress code and found out in the w
need Array help
This is what I have to do.
$teamname[1] = "Red Sox"
$teamname[2] = "Gian
Display data returned from Ajaxservices!!
I have a question about displaying results using ajax. I have part of the code below.
$.ajax({
Using unserialize()
Hi there.
I have some data in my database that is serialized.
e.g.
a:2:{i:0
Last Weeks sDate and eDate.
sDate - Start Date
eDate - End Date
I need to pull two dates for "Last Week" whi