ERROR PHP UNTUK KIRIM EMAIL DI CONTACT FORM html

Permisi saya mau nanya kiri kira di mananya yang salah ya saya punya html contact form sepertii ini untuk mengirim email

 <div id="smooth-contact"></div>
              <div class="col-md-8 col-sm-8">
                <div class="contact">

                  <h3 style="text-align=" left "">Write your message here</h3>

                  <form id="contact-form" class="form-2" action="contact.php">
                    <div class="row">

                      <div class="col-md-12 padding-0">

                        <div class="col-md-6">
                          <input name="name" id="name" type="text" placeholder="Your Name*" class="input">
                        </div>

                        <div class="col-md-6 ">
                          <input name="mail" id="mail" type="text" placeholder="Email*" class="input">
                        </div>

                      </div>

                      <div class="col-md-12 messages">

                        <textarea name="comment" id="comment" placeholder="Message" class="message"></textarea>

                        <input type="submit" value="Submit" id="submit_contact" class="submit-button">

                        <div id="msg" class="message"></div>

                      </div>

                    </div>
                  </form>

                </div>
              </div>

dan ini script contact.php nya

 <?php

	/* ==========================  Define variables ========================== */

	#Your e-mail address
	define("__TO__", "Aziez.samsung@gmail.com");

	#Message subject
	define("__SUBJECT__", "");

	#Success message
	define('__SUCCESS_MESSAGE__', "Your message has been sent. Thank you!");

	#Error message
	define('__ERROR_MESSAGE__', "Error, your message hasn't been sent");

	#Messege when one or more fields are empty
	define('__MESSAGE_EMPTY_FILDS__', "Please fill out  all fields");

	/* ========================  End Define variables ======================== */

	//Send mail function
	function send_mail($to,$subject,$message,$headers){
		if(@mail($to,$subject,$message,$headers)){
			echo json_encode(array('info' => 'success', 'msg' => __SUCCESS_MESSAGE__));
		} else {
			echo json_encode(array('info' => 'error', 'msg' => __ERROR_MESSAGE__));
		}
	}

	//Check e-mail validation
	function check_email($email){
		if(!@eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)){
			return false;
		} else {
			return true;
		}
	}

	//Get post data
	if(isset($_POST['name']) and isset($_POST['mail']) and isset($_POST['comment'])){
		$name 	 = $_POST['name'];
		$mail 	 = $_POST['mail'];
		$comment = $_POST['comment'];

		if($name == '') {
			echo json_encode(array('info' => 'error', 'msg' => "Please enter your name."));
			exit();
		} else if($mail == '' or check_email($mail) == false){
			echo json_encode(array('info' => 'error', 'msg' => "Please enter valid e-mail."));
			exit();
		} else if($comment == ''){
			echo json_encode(array('info' => 'error', 'msg' => "Please enter your message."));
			exit();
		} else {
			//Send Mail
			$to = __TO__;
			$subject = __SUBJECT__ . ' ' . $name;
			$message = '
			<html>
			<head>
			  <title>Mail from '. $name .'</title>
			</head>
			<body>
			  <table class="table">
				<tr>
				  <th align="right">Name:</th>
				  <td align="left">'. $name .'</td>
				</tr>
				<tr>
				  <th align="right">E-mail:</th>
				  <td align="left">'. $mail .'</td>
				</tr>
				<tr>
				  <th align="right">subject:</th>
				  <td align="left">'. $subject .'</td>
				</tr>
				<tr>
				  <th align="right">Comment:</th>
				  <td align="left">'. $comment .'</td>
				</tr>
			  </table>
			</body>
			</html>
			';

			$headers  = 'MIME-Version: 1.0' . "\r\n";
			$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
			$headers .= 'From: ' . $mail . "\r\n";

			send_mail($to,$subject,$message,$headers);
		}
	} else {
		echo json_encode(array('info' => 'error', 'msg' => __MESSAGE_EMPTY_FILDS__));
	}
 ?>

setelah saya coba submit di kontact form saya kok ada pessan error seperti ini

 {"info":"error","msg":"Please fill out all fields"}

apa karena saya masi menggunakan xampp dan belum di upload ke hosting,,???

terimakasih :)

avatar Aziez
@Aziez

193 Kontribusi 18 Poin

Diperbarui 6 tahun yang lalu

3 Jawaban:

Jawaban Terpilih

<form id="contact-form" class="form-2" action="contact.php">

kurang methodnya

<form id="contact-form" class="form-2" action="contact.php" method="post">

avatar rachmatsasongko
@rachmatsasongko

410 Kontribusi 426 Poin

Dipost 6 tahun yang lalu

ok thanks

avatar Aziez
@Aziez

193 Kontribusi 18 Poin

Dipost 6 tahun yang lalu

kalo dari localhost pakai phpmailer

avatar teguhpribadia
@teguhpribadia

19 Kontribusi 11 Poin

Dipost 6 tahun yang lalu

Login untuk ikut Jawaban