TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nikita
NA
56
10k
i want to sendemail php code for the following html section
Feb 12 2020 2:23 AM
1)appointment.html section
<
section
id
=
"service-single-area"
>
<
div
class
=
"container"
>
<
div
class
=
"row"
>
<
div
class
=
"col-lg-9 col-md-8 col-sm-12 col-xs-12 pull-right"
>
<
div
class
=
"service-single-content"
>
<
div
class
=
"appoinment-form"
>
<
div
class
=
"title"
>
<
h2
>
Make an Appoinment
</
h2
>
</
div
>
<
form
id
=
"appoinmentone"
name
=
"appointment"
action
=
"sendmail.php"
method
=
"post"
enctype
=
"text/plain"
>
<
div
class
=
"row"
>
<
div
class
=
"col-md-6"
>
<
input
type
=
"text"
name
=
"name"
value
=
""
placeholder
=
"Your Name*"
required
=
""
id
=
"name"
>
<
input
type
=
"email"
name
=
"email"
value
=
""
placeholder
=
"Your Mail*"
required
=
""
id
=
"email"
>
<
input
type
=
"text"
name
=
"phn"
value
=
""
placeholder
=
"Phone Number*"
required
=
""
id
=
"phone"
>
<
input
type
=
"date"
name
=
"date"
value
=
""
placeholder
=
"Apointment Date*"
required
=
""
id
=
"date"
>
</
div
>
<
div
class
=
"col-md-6"
>
<
select
class
=
"selectmenu"
>
<
option
selected
=
"selected"
id
=
"prod"
name
=
"services"
>
Select Service
</
option
>
<
option
id
=
"prod"
>
Commercial Aquaguard
</
option
>
<
option
id
=
"prod"
>
Industrial RO Plants
</
option
>
<
option
id
=
"prod"
>
Water Cooler
</
option
>
<
option
>
Commercial Vacuum Cleaner
</
option
>
<
option
>
Water Ionizers
</
option
>
</
select
>
<
textarea
name
=
"message"
placeholder
=
"Your Message.."
required
=
""
id
=
"messsage"
>
</
textarea
>
</
div
>
</
div
>
<
div
class
=
"row"
>
<
div
class
=
"col-md-12"
>
<
form
method
=
"post"
>
<
button
class
=
"thm-btn bg-1"
type
=
"submit"
onclick
=
"document.getElementById('appoinmentone').submit();"
>
Submit Now
</
button
>
</
form
>
</
div
>
</
div
>
</
form
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
section
>
2)here the refer php code for sending mail this is not for that appointment section its only for example purpose. i want to build same php code for that particular html section that i have given.
<?php
if
(isset(
$_POST
[
'email'
]))
{
// EDIT THE 2 LINES BELOW AS REQUIRED
$email_to
=
"
[email protected]
"
;
$email_subject
=
"Booking Received"
;
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
[
'telephone'
]) || !isset(
$_POST
[
'comments'
]))
{
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
$telephone
=
$_POST
[
'telephone'
];
// not required
$comments
=
$_POST
[
'comments'
];
// required
$checkin
=
$_POST
[
'SelectedDate1'
];
// required
$checkout
=
$_POST
[
'SelectedDate2'
];
// required
$Place
=
$_POST
[
'Place'
];
// required
$error_message
=
""
;
$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 First Name you entered does not appear to be valid.<br />'
;
}
if
(
strlen
(
$comments
) < 2)
{
$error_message
.=
'The Comments you entered do 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
.=
"First Name: "
. clean_string(
$name
) .
"\n"
;
$email_message
.=
"Email: "
. clean_string(
$email_from
) .
"\n"
;
$email_message
.=
"Telephone: "
. clean_string(
$telephone
) .
"\n"
;
$email_message
.=
"Comments: "
. clean_string(
$comments
) .
"\n"
;
$body
=
"Mail Send"
;
$msg
=
'Name:-'
.
$_POST
[
'name'
] .
"\n"
.
'Email:-'
.
$_POST
[
'email'
] .
"\n"
.
'Contact No:-'
.
$_POST
[
'telephone'
] .
"\n"
.
'Check In:-'
.
$_POST
[
'SelectedDate1'
] .
"\n"
.
'Check Out:-'
.
$_POST
[
'SelectedDate2'
] .
"\n"
.
'Place:-'
.
$_POST
[
'Place'
] .
"\n"
.
'cOMMENTS:-'
.
$_POST
[
'comments'
];
mail(
$email_to
,
$email_subject
,
$msg
);
echo
'<span style="color:#FFFFFF">Your E-mail has been sent !Thank you for contacting us. We will be in touch with you very soon.</span>'
;
?>
<!--
include
your own success html here
if
(
$send_email
)
{
echo
"Your E-mail has been sent !Thank you for contacting us. We will be in touch with you very soon."
;
}
else
{
echo
"E-mail sent was failed !"
;
} -->
<?php
}
?>
pls suggest me. the php code for that with a specific email format the fields are name, mobile, address, date, services, message etc. it displays into the email
Reply
Answers (
1
)
Payzone payment gateway Transaction Problem
Online accounting app WEB