php


How to submit a form and to receive it in a corresponding mail id?


I am using a form in a website, when i click the submit button, it should state that the form has submitted or not submitted message and the submitted form should be received by the mail id that has been provided in php..
The html code of the form with various inputs was,
<form id="ajax-contact" class="" method="post" action="mailer.php">
<fieldset>
<div class="row">
<div class="input col-xs-12 col-sm-12 padding-bottom-xs-50 padding-bottom-40">
<label class="input-label" for="name">
<span class="input-label-content font-second" data-content="name">name *</span>
</label>
<input class="input-field" type="text" name="name" id="name" required />
</div>
<div class="input col-xs-12 col-sm-6 padding-bottom-xs-50 padding-bottom-50">
<label class="input-label" for="email">
<span href="mailto:admin#seyali.com" class="input-label-content font-second" data-content="email">email *</span>
</label>
<input class="input-field" type="email" name="email" id="email" required />
</div>
<div class="input col-xs-12 col-sm-6 padding-bottom-xs-60 padding-bottom-50">
<label class="input-label" for="company">
<span class="input-label-content font-second" data-content="company">company</span>
</label>
<input class="input-field" type="text" name="company" id="company" />
</div>
<div class="message col-xs-12 col-sm-12 padding-bottom-xs-40 padding-bottom-30">
<label class="input-label" for="message *">
<span class="input-label-content font-second" data-content="message">Message *</span>
</label>
<textarea class="input-field textarea" name="message" id="message" required></textarea>
</div>
</div>
<div id="form-messages" class="form-message"></div>
<div class="col-xs-12 margin-top-30 text-center">
<button id="btn-submit" type="submit" value="Send" name="submit" id="send_mail" class="btn btn-animated btn-contact ripple-alone" data-text="send it"><span class="btn-icon"><span class="loader-parent"><span class="loader3"></span></span>
<div class="text-success" id="messages" style="font-weight: bold;padding-top:10px; color:#000!important; font-size:18px;"></div>
<span class="ink animate" style="height: 162px; width: 162px; top: -62.9844px; left: -45px;"></span>
</button>
</div>
</fieldset>
</form>
And the ajax code was,
$(document).ready(function(){
$("#contact_form").on("submit", function (event) {
event.preventDefault();
var form = $(this);
$.ajax({
type:"POST",
url:form.attr("action"),
data:form.serialize(),
beforeSend: function(){
form.find("#message").text("Sending Please wait...");
},
success: function(data){
form.find("#message").text(data);
form[0].reset();
setTimeout(function () {
form.find("#message").text("");
}, 5000);
},
error: function (error) {
form.find("#message").text(error.responseText);
setTimeout(function () {
form.find("#message").text("");
}, 5000);
}
});
});
});
The php code that i have tried as follows,
<?php
$email = $_POST['email'];
$to = "manirajdiv#gmail.com";
$subject = "Site: seyali.com Form: Contact Form";
$message = '<table class="table"><tr><td style="width:250px">Domain Name: </td><td style="width:250px">'. $domain_name. '</td></tr><tr><td style="width:250px">' . 'Form Name: </td><td style="width:250px">'. $form_name. '</td></tr>';
foreach ($_POST as $key=>$value) {
if($key != 'form_id'){
$message = $message .'<tr><td style="width:250px">'.$key.':</td><td style="width:250px"> '.$value.'</td></tr>';
}
}
$message = $message .'</table>';
$header = "From:no-reply#seyali.com";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-type: text/html\r\n";
$retval = mail ($to,$subject,$message,$header);
if( $retval == true ) {
http_response_code(200);
echo "Thanks for contacting us. We will get back to you shortly.";
}else {
http_response_code(500);
echo "Message could not be sent. Please try again later!";
}
?>
This may be a simple question but any help that solves my question would be more appreciable.. Kindly explain how to do this process of filling up the form and doing submit and to receive by the given mail id.. I tried with the above code but it is stating the error
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /seyalitechv3/mailer.php was not found on this server.</p> </body></html>
Kindly provide me a right solution regarding it..

Related Links

How to get different Wordpress category links within one php file?
What should an HTML 5 form submit when no value is set [duplicate]
How to present enum table property in Laravel Model
Send request “post” with hidden field and wordpress
PHP and MySQL pagination issue
php - performance of continue state
ZF2 Model getters and setters mismatching form element names
Selecting and matching data from 3 tables
How to get the request data in codeigniter
Format dynamic ul list generated by php
python doesn't write if call from php
while loop and session fix code
WP All Imports Custom Function
Login with Nativescript and Prestashop
Php Socket Programming Connection times out escpos-php
propagate drop down with basename of images in current directory php

Categories

HOME
opengl
macos-sierra
plesk
generics
seedstack
android-fragments
exchange-server
key
windows-10
ios-simulator
celery
mongoid
portable-class-library
elk-stack
turbojpeg
jint
specifications
clickable-image
heuristics
amazon-emr
bootstrap-switch
android-externalstorage
ex
temperature
closures
vertica
fosuserbundle
boomi
tableview
quantitative-finance
uri
hdmi
openbravo
sfml
microprocessors
mdns
netbios
osx-lion
nest
adminer
apptentive
creation
xerces-c
nppexec
keyboard-layout
cordys-opentext
djcelery
icepdf
julius-speech
liteide
realstudio
dredd
directwrite
amazon-elastic-beanstalk
connect-direct
email-forwarding
mpmovieplayercontroller
d3v4
multi-touch
data-management
coovachilli
xcode8-beta4
noclassdeffounderror
highlighting
apple-configurator
simian
exists
mathnet
polymerfire
teensy
pack
juniper-network-connect
ora-04091
supercomputers
wicked-gem
console.log
shell-extensions
string.format
berkeley-db-xml
forceclose
roxy-fileman
facebook-game-groups
saga
mousemotionlistener
contextswitchdeadlock
lynx
idispatch
image-formats
first-class
gamesalad
monocross
mmc3
play2-mini
canonicalization
jquery-1.4
mygeneration
explicit
resharper-5.1
aggregator
uninstaller
pinax
yahoo-maps
projectpier
ntruencrypt
database-cloning

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