php


Getting a Contact Field to send to an email address (PHP/HTML)


For my website I need my Contact Field Form to send to an email address, but when trying to do it, it sends a mass error string to the webpage at the top of it.
Id appreciate any help/advice if possible.
<form name="contactform" method="post" action="send_form_email.php">
<div class="col-sm-6">
<div class="footer-content">
<form role="form" id="footer-form">
<div class="form-group has-feedback">
<label class="sr-only" for="name">Name</label>
<input type="text" class="form-control" id="name" placeholder="Name" name="name2" required>
<i class="fa fa-user form-control-feedback"></i>
</div>
<div class="form-group has-feedback">
<label class="sr-only" for="email">Email Address</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email" required>
<i class="fa fa-envelope form-control-feedback"></i>
</div>
<div class="form-group has-feedback">
<label class="sr-only" for="message">Message</label>
<textarea class="form-control" rows="8" id="message" placeholder="Message" name="message" required></textarea>
<i class="fa fa-pencil form-control-feedback"></i>
</div>
<input type="submit" value="Submit" class="btn btn-default">
</form>
<?php
if(isset($_POST['email'])) {
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to = "asd#hotmail.com";
$email_subject = "Business Enquiries";
function died($error) {
// your error code can go here
echo "We are very sorry, but there were error(s) found with the form you submitted. ";
echo "These errors appear below.<br /><br />";
echo $error."<br /><br />";
echo "Please go back and fix these errors.<br /><br />";
die();
}
// validation expected data exists
if(!isset($_POST['name']) ||
!isset($_POST['email']) ||
!isset($_POST['message'])) {
died('We are sorry, but there appears to be a problem with the form you submitted.');
}
$name = $_POST['name']; // required
$email_from = $_POST['email']; // required
$message = $_POST['message']; // required
$error_message = "Some of the field you have entered are not correct.";
$email_exp = '/^[A-Za-z0-9._%-]+#[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
if(!preg_match($email_exp,$email_from)) {
$error_message .= 'The Email Address you entered does not appear to be valid.<br />';
}
$string_exp = "/^[A-Za-z .'-]+$/";
if(!preg_match($string_exp,$name)) {
$error_message .= 'The Name you entered does not appear to be valid.<br />';
}
if(strlen($message) < 2) {
$error_message .= 'The message you entered does not appear to be valid.<br />';
}
if(strlen($error_message) > 0) {
died($error_message);
}
$email_message = "Form details below.\n\n";
function clean_string($string) {
$bad = array("content-type","bcc:","to:","cc:","href");
return str_replace($bad,"",$string);
}
$email_message .= "Name: ".clean_string($name)."\n";
$email_message .= "Email: ".clean_string($email_from)."\n";
$email_message .= "Message: ".clean_string($message)."\n";
// create email headers
$headers = 'From: '.$email_from."\r\n".
'Reply-To: '.$email_from."\r\n" .
'X-Mailer: PHP/' . phpversion();
#mail($email_to, $email_subject, $email_message, $headers);
?>
<!-- include your own success html here -->
Thank you for contacting Visionary Designs. We will be in touch with you very soon.
<?php
}
?>

Related Links

Failed opening required '../vendor/autoload.php'
Compare between Two dates in php [duplicate]
Altering another document in Doctrine ODM PreUpdate event
FB access token is empty without any FB exception thrown from PHP SDK v5
Stream a PDF file in Laravel 5.2
BroadcastOn not firing in laravel 5.3?
How to execute a Symfony command as cron job?
use laravel Authentication in pure php scripts
show the data from complex json data in php
.htacces redirect subdomain to folder
Plesk horde mail error. Cannot allocate memory
Codeigniter 3 - can I get image upload's url from 3 images?
How I can format this line into formatted code using regex
How to send email with PHPMailer from a google mail address?
ZF2 injecting InputFilter into Fieldset not working automatically
Is there a way of installing PHP with --enable-maintainer-zts using apt-get?

Categories

HOME
elasticsearch
openshift
long-integer
add-on
devexpress
hid
autocomplete
tfs2015
minecraft
wagtail
static-analysis
scheduler
tup
azure-logic-apps
yahoo
xamarin-zebble
createjs
multi-step
sql-injection
dashdb
maven-surefire-plugin
function-points
web-push
data-collection
crud
python-imageio
sendmessage
sales
guice
credit-card
vcenter
winrm
restful-architecture
bean-validation
redgate
xll
tidal-scheduler
reset
resampling
elasticsearch-aggregation
sendinput
doctrine-extensions
cordova-ios
openstack-glance
dblink
nrf51
perl-data-structures
annotatorjs
mathjs
dcount
livecycle
conan
xcode8-beta4
right-to-left
unsigned
sharepoint-apps
openmrs
linuxbrew
in-app-billing
cfwheels
highest
blank-line
screen-orientation
enaml
unhandled
physicsjs
prism-4
multivariate-testing
xhprof
accessory
django-sites
iosched
compiler-flags
stty
web-frameworks
proc-open
ckeditor.net
handshake
semantic-merge
jdom
flymake
autosize
glx
mvcrecaptcha
asio
data-dump
representation
nosetests
sql-parametrized-query
kext
bll
active-record-query
android-2.1-eclair
ios-4.2
explicit
multiple-users
android-input-method
iphone-sdk-4.3
wmd-editor
database-cloning
icon-language

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App