All data is not sent with form id=”contactform” and all data sent without id=”contactform”

All data is not sent with form id=”contactform” and all data sent without id=”contactform”

Hi i am working with a onepage website
the main issue is with form

if i do this

<form method="post" action="scripts/contact.php" role="form" name="contactform" id="contactform">

the form is submitted but only few data is delivered in email

but if i do this

<form class="form" method="post" action="scripts/contact.php"> 

the form is submitted and all the data is delivered in email but in this the main issue is the successful report page is displayed in a new page .

My Form is ;

<div class="form-group">
    <label for="fullname" class="col-sm-3 col-xs-12">Full name</label>
    <div class="col-sm-9 col-xs-12">
        <input type="text" class="form-control" name="name" id="name" placeholder="Your Name" required>
<div class="form-group">
    <label for="phone" class="col-sm-3 col-xs-12">Phone</label>
    <div class="col-sm-9 col-xs-12">
        <input type="text" class="form-control" name="phone" id="phone" placeholder="Your Phone" required>
<div class="form-group">
    <label for="email" class="col-sm-3 col-xs-12">Email</label>
    <div class="col-sm-9 col-xs-12">
        <input type="email" class="form-control" name="email" id="email" placeholder="your Email" required>

<div class="form-group">
    <label for="pdate" class="col-sm-3 col-xs-12">Pick up date</label>
    <div class="col-sm-9 col-xs-12">
        <input type="text" class="form-control" name="pdate" id="pdate" placeholder="Pick up date" required>

<div class="form-group">
    <label for="paddress" class="col-sm-3 col-xs-12">Pick up</label>
    <div class="col-sm-9 col-xs-12">
        <input type="text" class="form-control" name="paddress" id="paddess" placeholder="Pick up Address" required>

<div class="form-group">
    <label for="daddress" class="col-sm-3 col-xs-12">Destination</label>
    <div class="col-sm-9 col-xs-12">
        <input type="text" class="form-control" name="daddress" id="daddress" placeholder="Destination Address" required>
<button type="submit" class="btn btn-primary btn-lg btn-block">Book Now</button>



if(!$_POST) exit;

 * just replace email address with your email address
$address = "[email protected]"; 

// Email address verification, do not edit this part.
function isEmail($email) {
	return(preg_match("/^[-_.[:alnum:]][email protected]((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email));

if (!defined("PHP_EOL")) define("PHP_EOL", "\r\n");

$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$pdate = $_POST['pdate'];
$paddress = $_POST['paddress'];
$daddress = $_POST['daddress'];
$subject = $_POST['subject'];
$msg = $_POST['msg'];

if(trim($name) == '') {
	echo '<div class="error_message">Please Enter Your Name :) .</div>';
} else if(trim($email) == '') {
	echo '<div class="error_message"> Please enter a valid email address :) .</div>';
} else if(!isEmail($email)) {
	echo '<div class="error_message">You have enter an invalid e-mail address.</div>';

/*if(trim($subject) == '') {
	echo '<div class="error_message">Please enter a subject.</div>';
} else if(trim($msg) == '') {
	echo '<div class="error_message">Please enter your message.</div>';
} */

if(get_magic_quotes_gpc()) {
	$msg = stripslashes($msg);

// Configuration option.
// i.e. The standard subject will appear as, "You've been contacted by  ."
// Example, $e_subject = '$name . ' has contacted you via Your Website.';
$e_subject = 'You\'ve been contacted From website by ' . $name . '.';

// You can change this if you feel that you need to.

$e_body = "You have been contacted by $name with regards to $subject, their additional message is as follows." . PHP_EOL . PHP_EOL;

$e_content = "\"$msg\"" . PHP_EOL . PHP_EOL;

$e_body = "This mail Send by $name" . PHP_EOL . PHP_EOL;
$e_email = "Email: $email" . PHP_EOL . PHP_EOL;
$e_phone = "Phone: $phone" . PHP_EOL . PHP_EOL;
$e_pdate = "Pick up date : $pdate" . PHP_EOL . PHP_EOL;
$e_paddress = "Pick Up address : $paddress" . PHP_EOL . PHP_EOL;
$e_daddress = "Destination Address: $daddress" . PHP_EOL . PHP_EOL;

$e_reply = "You can contact $name via email, $email or via phone $phone";

$msg = wordwrap($e_body .$e_email. $e_phone. $e_pdate. $e_paddress. $e_daddress. $e_reply, 70);

/*$e_content = "\"$msg\"" . PHP_EOL . PHP_EOL;
$e_reply = "You can contact $name via email, $email ";

$msg = wordwrap( $e_body . $e_content . $e_reply, 70 );*/

$headers = "From: $email" . PHP_EOL;
$headers .= "Reply-To: $email" . PHP_EOL;
$headers .= "MIME-Version: 1.0" . PHP_EOL;
$headers .= "Content-type: text/plain; charset=utf-8" . PHP_EOL;
$headers .= "Content-Transfer-Encoding: quoted-printable" . PHP_EOL;

if(mail($address, $e_subject, $msg, $headers)) {

	// Email has sent successfully, echo a success page.

	echo "<fieldset>";
	echo "<div id='success_page'>";
	echo "<h1>Email Sent Successfully.</h1>";
	echo "<p>Thank you <strong>$name</strong>, your message has been submitted to us.</p>";
	echo "<p>We Will reply asap :)</p>";
	echo "</div>";
	echo "</fieldset>";

} else {

	echo 'ERROR!';

} is

jQuery(document).ready(function() {

    .on('click', function() {
      var btn = $(this);
      setTimeout(function() {
      }, 3000);

  $('#contactform').submit(function() {

    var action = $(this).attr('action');

    $("#message").slideUp(750, function() {
      $.post(action, {
          name: $('#name').val(),
          email: $('#email').val(),
          phone: $('#phone').val(),
          pdate: $('#pdate').val(),
          paddress: $('#paddress').val(),
          daddress: $('#daddress').val(),
          subject: $('#subject').val(),
          msg: $('#msg').val()
        function(data) {
          document.getElementById('message').innerHTML = data;
          if (data.match('success') != null)




    return false;



can anyone please help me with this ?

Thank you !

I’ve edited your post for readability by formatting it and removing some of the extra whitespace. In the future, when posting code, use the “preformatted text” button (it looks like </>) to make your code readable.

When I ran your code, there where PHP errors which need to be fixed.

You refer to a form input with id of paddress, but in your HTML form, you have an input with id of `paddess".

You refer to an input with id of subject, but I do not see an input with id of subject in your HTML form.

Lastly, you refer to an input with id of msg, but I do not see an input with id of msg in your HTML.

You should have seen these error messages when you run your code on the server. If you are not, you need to make sure to change your php.ini settings to display all errors.

If you’re doing $.post() then you need to prevent the form from submitting.

$(’#contactform’).submit(function() {


$(’#contactform’).submit(function(evt) {

@raz Forgot to mention that I added the preventDefault() to get your code to see the errors.

Thanks for mentioning that @kerafyrm02.

Thank you Everyone for your kind help,
i sorted this out as i missed adding the error message for some fields so there was the error.

Thank you Once again