I could receive the email but my php has some problem which maks the receving email looks strange, and can't use reply function on outlook. anyone could help me improve it. thank you.

this contact.php

<body>
<?php
$field_firstname = $_POST['firstname'];" ".$_POST['lastname'];
$field_emailaddress= $_POST['emailaddress'];
$field_telepohone = $_POST['telephone'];
$field_country = $_POST['country'];
$field_business = $_POST['business'];
$field_comments = $_POST['comments'];

$mail_to = 'info@ABC.com';
$subject = 'Message from a site visitor '.$field_name;

$body_message  = 'From:   '.$field_name."\n";
$body_message .= 'E-mail: '.$_POST['emailaddress']."\n";
$body_message .= 'Message: \n'.$_POST['emailaddress']."\n";
$body_message .=  $_POST['telephone']."\n";
$body_message .=  $_POST['country']."\n";
$body_message .=  $_POST['business']."\n";
$body_message .=  $_POST['comments'];

$headers = 'From: '.$_POST['emailaddress'].'\r\n';
$headers .= 'Reply-To: '.$_POST['emailaddress'].'\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.href = "http://www.ABC.com/thankyou.html";
//-->

    </script>
<?php
}
else { ?>
    <script language="javascript" type="text/javascript">
        alert('Message failed. Please check the items required');

        <!--
window.location.href = "http://www.ABC.com/contact.html";
//-->

    </script>
<?php
}
?>

this is contact.html

<form action="contact.php" method="post" name="form1" target="_blank" class="email" id="form1" onsubmit="MM_validateForm('firstname','','R','lastname','','R','emailaddress','','NisEmail','comments','','R');return document.MM_returnValue">
      <p>If you need more information about our inspection, sourcing, auditing, and verification service, <br />
        <br />
        pls contact below address or just fill in the form below, our customer service will get you back <br />
        <br />
      as soon as possible. thank you for considering ABC!</p>
      <p>First Name: 
        &nbsp;&nbsp;&nbsp;
        <label for="firstname"></label>
        &nbsp;&nbsp;&nbsp;
        <input type="text" name="firstname" id="firstname" />
        <br />
        <br />
        Lsat Name: 
        <label for="lastname"></label>
        &nbsp;&nbsp;&nbsp;
        &nbsp;&nbsp;&nbsp;
        <input type="text" name="lastname" id="lastname" />
        <br />
        <br />
        Email Address:
        &nbsp;&nbsp;
        <label for="emailaddress"></label>
        <input type="text" name="emailaddress" id="emailaddress" />
        <br />
        <br />
        Telephone:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<label for="telephone2"></label>
        <input type="text" name="telephone" id="telephone" />
        <label for="TEL"></label>
        <br />
        <br />
        Country:
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <label for="country"></label>
        <select name="country" id="country">
          <option>Australia</option>
          <option>Austria</option>
          <option>Belgium</option>
          <option>Czech Republic</option>
          <option>Denmark</option>
          <option>Finland</option>
          <option>France</option>
          <option>Germany</option>
          <option>Greece</option>
          <option>Hungary</option>
          <option>Italy</option>
          <option>Netherlands</option>
          <option>Norway</option>
          <option>Poland</option>
          <option>Romania</option>
          <option>Russia</option>
          <option>Spain</option>
          <option>Sweden</option>
          <option>Switzerland</option>
          <option>United Kingdom</option>
          <option>Canada</option>
          <option>Mexico</option>
          <option>United States of America</option>
          <option>Argentina</option>
          <option>Brazil</option>
          <option>New Zealand</option>
          <option>Egypt</option>
          <option>Iran</option>
          <option>Israel</option>
          <option>Kuwait</option>
          <option>Saudi Arabia</option>
          <option>Turkey</option>
          <option>Japan</option>
          <option>South Korea</option>
          <option>Vietnam</option>
          <option>other</option>
        </select>
        <br />
        <br />
        Business:
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <label for="business"></label>
        <select name="business" id="business">
          <option>wholesale</option>
          <option>retail</option>
          <option>industrial</option>
          <option>services</option>
          <option>distributor</option>
          <option>manufacturer</option>
          <option>importer</option>
          <option>other</option>
        </select>
        <label for="telephone"></label>
        <label for="FAX"></label>
        <br />
        <br />
        Comments:<br />
        <br />
        <label for="comments"></label>
        <textarea name="comments" id="comments" cols="45" rows="5"></textarea>
        <br />
        <br />
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <input name="submit" type="submit" id="submit" onclick="MM_validateForm('firstname','','R','lastname','','R','emailaddress','','RisEmail','telephone','','NisNum','comments','','R');return document.MM_returnValue" value="Submit" />
        <br />
      </p>
    </form>

another problem is that the verification function doesn't work, people could send me blank email, but when I try myself, it works. thank you for you help.

Member Avatar for LastMitch

@cmabill

I could receive the email but my php has some problem which maks the receving email looks strange, and can't use reply function on outlook.

Can you explain more in detail what looks strange?

another problem is that the verification function doesn't work, people could send me blank email, but when I try myself, it works. thank you for you help.

Where is your verification code? I assume it must be in javascript?

thank you LastMitch, pls see attached shot, when I click reply button, it looks like the email address is not correct, I don't have verification code, I mean that people could sned my email without filling in name, telephone, email adress etc.

122214

Member Avatar for LastMitch

@cmabill

when I click reply button, it looks like the email address is not correct

In your contact.php on line 22 just take the period off:

From this:

$headers .= 'Reply-To: '.$_POST['emailaddress'].'\r\n';

to this:

$headers = 'Reply-To: '.$_POST['emailaddress'].'\r\n';

I don't have verification code, I mean that people could sned my email without filling in name, telephone, email adress etc.

This code is onsubmit="MM_validateForm() it's javascript that verified the info before it is send.

Why do you need this code onsubmit="MM_validateForm() if you don't need it to be validate the info:

<form action="contact.php" method="post" name="form1" target="_blank" class="email" id="form1" onsubmit="MM_validateForm('firstname','','R','lastname','','R','emailaddress','','NisEmail','comments','','R');return document.MM_returnValue">

You can just used this:

<form action="contact.php" method="post" name="form1" target="_blank" class="email" id="form1">

Hello LastMitch

thank you for your time and help, it works better now, I really appreciate it. sorry that I am not a web designer and could understand very profund meaning but anyway, it works. I just want to make my website a little better.

Member Avatar for LastMitch

@cmabill

I really appreciate it. sorry that I am not a web designer and could understand very profund meaning but anyway, it works. I just want to make my website a little better.

What do you mean you're not a web designer? The code you provided is part of web designing.

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.