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

HHVM - imagettftext(): “No such file or directory”
Yii - How to Show Value of Array in CGridView?
same script and software throws exception on windows
Undefined variable in actionblock template
MySQL - How can I/workaround ordering by the result of a group function
Create SEO-friendly URL from php using htaccess
Php - allow spaces in rewriteRule
how to update customer account balance when in INSERT query execute using mysql and php
query does all rows correct except for row 9
WP query both post type and category
Log PHP exceptions in Laravel Log
Laravel 4 Hybridauth Server not found
How Can I Properly put this html in my PHP script
Request parameters in PHP on HHVM
How to limit users in login system to one vote per post? [closed]
How to recompose my codes on PhpStorm

Categories

HOME
opengl
oracle
svn
blast
eclipse-plugin
workflow
scroll
mousemove
subdomain
dry
loopbackjs
plaid
clone
joomla3.2
telegraf
xamarin-zebble
xades4j
cqrs
spring-amqp
jquery-file-upload
phonegap-build
mixpanel
gravity
string-formatting
adobe-illustrator
quantitative-finance
chronicle-queue
unordered-multimap
web-config-transform
history.js
oracleforms
pyspark-sql
bobo-browse.net
basic-authentication
splunk-query
source-insight
premake
progid
fotorama
lxml
osx-lion
shapeless
markov-chains
java-stream
cordys-opentext
nanogallery
forms-authentication
hidden-markov-models
python-sounddevice
robust
minikube
expandablelistview
linq-to-excel
django-static-precompiler
icecast
entropy
android-webservice
apache-modules
emacs25
boost-compute
researchkit
nvda
django-testing
seccomp
xcode8-beta4
teamviewer
taco
management-studio-express
wepay
pack
ajax4jsf
darwin
bootstrap-wysiwyg
erlog
whitespace-language
gflags
kognitio-wx2
nhibernate-criteria
thoughtworks-go
loginview
box2dweb
distributed-r
code-complexity
pacman
itunes-sdk
significant-digits
multiple-dispatch
daap
xcode4.5
workflow-manager-1.x
prototypal-inheritance
expression-web
firefly-mv
nsconnection
anonymous-types
channelfactory
formal-semantics
downgrade
aggregator
tabbarcontroller
firephp
bindable-linq

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