hi, hope if someone can help me, my conact form works and i receive the mail, but it shows me just the email and phone
this is a test:

Email = test@live.fr
Name =
Phone = 06 09 56 89 45
Message = Email = forza-ayoub@live.fr
Name =
Phone = 06 09 56 89 45

form code is from page html, and the 2nd code is the php page

<form action="#" method="post" id="cform" name="cform">
              <ul id="homehireus" class="hireform contactform">
                <li>
                  <label>Name:<span class="required">*</span></label>
                  <input name="name" id="name" type="text" value="" tabindex="1">
                </li>
                <li>
                  <label>Phone:</label>
                  <input name="phone" id="phone" type="text" value="" tabindex="3">
                </li>
                <li>
                  <label>Email:<span class="required">*</span></label>
                  <input name="email" id="email" type="text" value="" tabindex="2">




<?php 

// EDIT THE FOLLOWING LINE BELOW AS REQUIRED

$send_email_to = "admin@egrappler.com";

function send_email($name,$email,$phone,$subject,$message)
{
  global $send_email_to;  
  if($message=='message')$message='';
  $headers = "MIME-Version: 1.0" . "\r\n";
  $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
  $headers .= "From: ".$email. "\r\n";
  $message = "<strong>Email = </strong>".$email."<br>";  
  $message .= "<strong>Name = </strong>".$name."<br>";     
  $message .= "<strong>Phone = </strong>".$phone."<br>";     
  $message .= "<strong>Message = </strong>".$message."<br>";
  @mail($send_email_to, $subject, $message,$headers);
  return true;
}

function validate($name,$email,$phone,$message,$subject)
{
  $return_array = array();
  $return_array['success'] = '1';
  $return_array['name_msg'] = '';  
  $return_array['email_msg'] = '';
  $return_array['phone_msg'] = '';
  $return_array['message_msg'] = '';
  $return_array['subject_msg'] = '';

 if($email == '')
  {
    $return_array['success'] = '0';
    $return_array['email_msg'] = 'email is required';
  }
  else
  {
    $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,4}$/';
    if(!preg_match($email_exp,$email)) {
      $return_array['success'] = '0';
      $return_array['email_msg'] = 'Enter valid email.';  
    }
  }

  if($name == '')
  {
    $return_array['success'] = '0';
    $return_array['name_msg'] = 'Name is required';
  }
  else
  {
     $string_exp = "/^[A-Za-z .'-]+$/";
    if (!preg_match($string_exp, $name)) {
      $return_array['success'] = '0';
     $return_array['name_msg'] = 'Enter valid Name.';
    }
  }

  if($phone == '')
  {
    $return_array['success'] = '0';
    $return_array['phone_msg'] = 'Phone is required';
  }
  else
  {
    $string_exp = "/^[A-Za-z .'-]+$/";
     if (!preg_match($string_exp, $phone)) {
       $return_array['success'] = '0';
     $return_array['phone_msg'] = 'Enter valid Phone.';
    }
  }

  if($subject == '')
  {
    $return_array['success'] = '0';
    $return_array['subject_msg'] = 'Subject is required';
  }

  if($message == '')
  {
    $return_array['success'] = '0';
    $return_array['message_msg'] = 'Message is required';
  }
  else
  {
    if (strlen($message) < 2) {
      $return_array['success'] = '0';
      $return_array['message_msg'] = 'Enter valid Message.';
    }
  }  

  return $return_array;
}

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];

$return_array = validate($name,$email,$phone,$message,$subject);
if($return_array['success'] == '1')
{
  send_email($fname,$email,$phone,$subject,$message);
}

header('Content-type: text/json');
echo json_encode($return_array);
die();

?>
send_email($fname,$email,$phone,$subject,$message);

You are using $fname instead of $name, that's the first thing I see that might go wrong. And where is the textarea/input in your form with the name "message"? Can it even get set? :o

i fixed the name now, but for the message it shows me "Message = Email = test@hotmail.com", but dont show me the my message

What is the name if the <input> element in your form in which the message is typed? Has it been named correctly? Is its name attribute really set to "message", so that $_POST['message'] actually contains a value?

E.g. do you have something like:

<input name="message"> or <textarea name="message"></textarea>?

<form action="#" method="post" id="cform" name="cform">
              <ul id="homehireus" class="hireform contactform">
                <li>
                  <label>Name:<span class="required">*</span></label>
                  <input name="name" id="name" type="text" value="" tabindex="1">
                </li>
                <li>
                  <label>Phone:</label>
                  <input name="phone" id="phone" type="text" value="" tabindex="3">
                </li>
                <li>
                  <label>Email:<span class="required">*</span></label>
                  <input name="email" id="email" type="text" value="" tabindex="2">
                </li>
                <li>
                  <label>Subject:<span class="required"></span></label>
                  <input name="subject" id="subject" type="text" value="" tabindex="4">
                </li>
                <li>
                  <input type="button" id="send-message" value="Send Details To Wee" tabindex="6">
                  <div id="output" class="contactpage-msg"></div>
                </li>
                <li>
                  <label>Message:<span class="required"></span></label>
                  <textarea name="message" id="message" tabindex="5"></textarea>
                </li>
              </ul>
            </form>

it's <textarea name="message"></textarea>

Sorry for the late reply! It could be that this if-else is triggered:

if($message=='message')$message='';

Have you checked the values of your variables before you execute your send_email() function?

For example, try this:

$name = $_POST['name'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$message = $_POST['message'];
$subject = $_POST['subject'];

$return_array = validate($name,$email,$phone,$message,$subject);


// Let's see what's in our variables:
echo '<p>Our POST variables look like this:</p><pre>'; print_r($_POST); echo '</pre>';

echo '<p>Our other variables look like this:</p>';
echo '<p>';
echo '$name: ' . $name . '<br>';
echo '$phone: ' . $phone . '<br>';
echo '$email: ' . $email . '<br>';
echo '$message: ' . $message . '<br>';
echo '$subject: ' . $subject . '<br>';
echo '</p>';

echo '<p>We\'re assuming that everything is correct, so an email will now be sent..</p>';


if($return_array['success'] == '1')
{
    send_email($name,$email,$phone,$subject,$message);
}

thanks a lot for this resource.

i want to know how can i use this.thats mean ,how can i connect this ,how can i save this and control & maintain this.hope some one tell me about this specially minitauros.

What exactly is it that you're asking? Are you asking how you can use this code? Or how to build a contact form? Or..? :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.