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
Character Set Setup
Whats the best character set to use if you want every character to work, and also how do you make yo
Weird Problem with curl while sending data
I am facing a weird problem with sending data to a site via curl.
If i send the value by this
Connection Timeout
I'm using xmii 12.0
I'm calling a transaction as a web service from a windows application
$_POST
Hi, I have 2 seperate php files, and i want my $_POSt["fname"] To go into both of them, Fo
Why does first ever HttpSendRequest take longer?
I promise this isn't as simple as it sounds. I'm wondering why the the first ever call to HttpSendRe
Converting RGB values to HEX
Code: <?PHP
$file_handle = fopen("colors/rgb.csv", "r");
wh
Thread in PHP
Thread in PHP
Some basic use and basic code for thread in php
This is my question?
Problem with array max size.
Hi to everyone,
I've got a homework about filling a bidimensional array un spiral shape, I alre
Bit manipulation program with binary operations
My homework is to create a program to scan in and add binary numbers and print them like so
Forms Authentication and Refresh at Login page
Hello,
When I try to press the Login button in my webapplication at my login.aspx page nothing h