Contact form missing parts working

Ive tried rechecked code googled still no able to fix error

I get the email but missing 2 parts in type and date example below

From: Person Name
E-mail: [email protected]
Phone: 034353543
Type:
Source: domain.com
Date:

error message

[11-May-2020 21:13:15 Europe/London] PHP Notice: Undefined index: subject in /home/php/register.php on line 9
[11-May-2020 21:13:15 Europe/London] PHP Notice: Undefined index: date1 in /home/php/register.php on line 13

contact.php

  <form id="register-form" class="register-form register" action="register.php" method="post">
                                
                    
                                <input class="register-input white-input" required="" name="register_names" placeholder="Full Name" type="text">
                            
                                <input class="register-input white-input" required="" name="register_email" placeholder="Email Adress*" type="email">

                                <input class="register-input white-input" required="" name="register_phone" placeholder="Phone Number*" type="text">
                                
                                 <select class="register-input white-input" required="" name="register_subject">
  <option value="">Please select type*</option>
  <option value="New Bathroom">New Bathroom</option>
  <option value="Fix Shower">Fix Shower</option>
  <option value="Fix Toliet">Fix Toliet</option>
<option value="Fix Bath">Fix Bath</option>								 
  <option value="New Shower">New Shower</option>
</select> 
                               
                                <input value="Submit request callback!" class="register-submit" type="submit">
                                <input type="hidden" id="source" name="register_source" value="website.com">
                                <input type="hidden" name="date1" value="<?php $date1 = date("d-m-Y H:i:s");echo $date1?>"/>


                                    
                            </form>

custom js file

	/* ========================================================== */
	/*   Register                                                 */
	/* ========================================================== */
	
	$('#register-form').each( function(){
		var form = $(this);
		//form.validate();
		form.submit(function(e) {
			if (!e.isDefaultPrevented()) {
				jQuery.post(this.action,{
					'names':$('input[name="register_names"]').val(),
					'email':$('input[name="register_email"]').val(),
					'phone':$('input[name="register_phone"]').val(),
					'subject':$('input[name="register_subject"]').val(),
					'source':$('input[name="register_source"]').val(),
					'date1':$('input[name="register_date1"]').val(),
				},function(data){
					form.fadeOut('fast', function() {
						$(this).siblings('p.register_success_box').show();
					});
				});
				e.preventDefault();
			}
		});
	})

Send email php

<?php

$field_first_name = $_POST['names'];

$field_email = $_POST['email'];

$field_phone = $_POST['phone'];

$field_subject = $_POST['subject'];

$field_source = $_POST['source'];

$field_date1 = $_POST['date1'];

$mail_to = '[email protected];

$subject = 'A New Enqury '.$field_first_name;

$body_message = 'From: '.$field_first_name."\n";

$body_message .= 'E-mail: '.$field_email."\n";

$body_message .= 'Phone: '.$field_phone."\n";

$body_message .= 'Type: '.$field_subject."\n";

$body_message .= 'Source: '.$field_source."\n";

$body_message .= 'Date: '.$field_date1."\n";

$headers = 'From: '.$field_email."\r\n";

$headers .= 'Reply-To: '.$field_email."\r\n";

$mail_status = mail($mail_to, $subject, $body_message, $headers);


if ($mail_status) { ?>
	<script language="javascript" type="text/javascript">
		//alert('Thank you for the message. We will contact you shortly.');
		window.location = 'index.html';
	</script>
<?php
}
else { ?>
	<script language="javascript" type="text/javascript">
		//alert('Message failed. Please, send an email to [email protected]');
		window.location = 'index.html';
	</script>
<?php
}


?>

Your name for your subject drop-down is “register_subject” not just subject!

And, remove the check for date1 from the jquery check because it is hidden and should never be empty.

Good luck with this…

Sponsor our Newsletter | Privacy Policy | Terms of Service