title: Sending mail from html through php will return to php page. It should be in the same contact form. How to do it?
body: <p>I have a html page with all images and other text. Below i have the contact form. i am new to php. I have used php to send mail. But when i click on send button,it is going to backend.php. And i have a blank page. What i need is it should in the same page. I have done some javascript to show and hide div's. With this i am showing a thank u msg in the same page. But i dont want to redirect browser to show it is going to backend.php.TO be in the same page i have redirected php to another window.</p>
  
  <p>My code is -
  backend.php</p>
  
  <pre><code>&lt;?php
  if($_POST['message']) 
  {
      $body = "Name: ".$_POST['name'];
      $body .= "&lt;br&gt;Email: ".$_POST['email'];
      $body .= "&lt;br&gt;Phone/Mobile: ".$_POST['phone']
      $body .= "&lt;br&gt;Address: ".$_POST['address']
      $body .= "&lt;br&gt;Message: ".$_POST['msg']
      if(mail("Info@travelfoodservices.com","Subjects",$body))
          echo 'true';
      else echo 'false;';
  }
  ?&gt;
  </code></pre>
  
  <p>form code -</p>
  
  <pre><code>&lt;form onsubmit="return validateFormOnSubmit(this)"  action="backend.php" method="post" target="_blank"&gt;
  &lt;table align="left"&gt;
  &lt;tbody&gt;
    &lt;tr&gt;
  &lt;td align="left"&gt;&lt;label for="name"&gt;Enter your name:&lt;/label&gt; &lt;label style="color:red;display:none;font-size:18px;" Id="namestar"&gt;*&lt;/label&gt;&lt;/td&gt;    
  
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td align="left"&gt;&lt;input Id="name" name="name" style="width:515px;" size="35" maxlength="50" type="text"&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr &gt;&lt;td height="12px"/&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="left"&gt;&lt;label for="email"&gt;Email Address:&lt;/label&gt; &lt;label style="color:red;display:none;font-size:18px;" Id="emailstar"&gt;*&lt;/label&gt;&lt;/td&gt;    
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td align="left"&gt;&lt;input Id="email" name="email" style="width:515px;"  type="text"&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td height="12px"/&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="left"&gt;&lt;label for="phone"&gt;Phone/Mobile:&lt;/label&gt;&lt;label style="color:red;font-size:18px;display:none;" Id="phonestar"&gt;*&lt;/label&gt;&lt;/td&gt;    
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td align="left"&gt;&lt;input Id="phone" name="phone" style="width:515px;"  type="text"&gt;&lt;/td&gt;&lt;/tr&gt;
  
  &lt;tr&gt;&lt;td height="12px"/&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="left"&gt;&lt;label for="address"&gt;Your Address:&lt;/label&gt;&lt;label style="color:red;font-size:18px;display:none;" Id="addressstar"&gt;*&lt;/label&gt;&lt;/td&gt;    
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td align="left"&gt;&lt;input id="address" name="address" style="width:515px;"  type="text"&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td height="12px"/&gt;&lt;/tr&gt;
  &lt;tr&gt;
  &lt;td align="left"&gt;&lt;label for="msg"&gt;Enter Your Comments / Suggestions / Enquiries&lt;/label&gt;&lt;label style="color:red;font-size:18px;display:none;" Id="messagestar"&gt;*&lt;/label&gt;&lt;/td&gt;    
  &lt;/tr&gt;
  &lt;tr&gt;&lt;td align="left"&gt;&lt;textarea id="msg" name="msg" style="width:515px;height:100px;"  type="text"&gt;&lt;/textarea&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td height="12px"/&gt;&lt;/tr&gt;
  &lt;tr&gt;
  
  &lt;td align="right"&gt;&lt;table align="left"&gt;
  &lt;tbody&gt;
    &lt;tr &gt;
  &lt;td style="width:160px;"/&gt;
  &lt;td style="width:250px;" &gt;&lt;label Id="mandatory" style="display:none;color:red;" &gt;* Mandatory fields&lt;/label&gt;&lt;/td&gt;
  &lt;td &gt;&lt;input   type="submit" name="send" value="send" /&gt;&lt;/td&gt;&lt;td &gt;
  &lt;input   type="reset" name="reset" value="reset" onclick="resetAll()" /&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  </code></pre>