Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3932230
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:26:05+00:00 2026-05-19T23:26:05+00:00

I have a html page with all images and other text. Below i have

  • 0

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.

My code is –
backend.php

<?php
if($_POST['message']) 
{
    $body = "Name: ".$_POST['name'];
    $body .= "<br>Email: ".$_POST['email'];
    $body .= "<br>Phone/Mobile: ".$_POST['phone']
    $body .= "<br>Address: ".$_POST['address']
    $body .= "<br>Message: ".$_POST['msg']
    if(mail("Info@travelfoodservices.com","Subjects",$body))
        echo 'true';
    else echo 'false;';
}
?>

form code –

<form onsubmit="return validateFormOnSubmit(this)"  action="backend.php" method="post" target="_blank">
<table align="left">
<tbody>
  <tr>
<td align="left"><label for="name">Enter your name:</label> <label style="color:red;display:none;font-size:18px;" Id="namestar">*</label></td>    

</tr>
<tr><td align="left"><input Id="name" name="name" style="width:515px;" size="35" maxlength="50" type="text"></td></tr>
<tr ><td height="12px"/></tr>
<tr>
<td align="left"><label for="email">Email Address:</label> <label style="color:red;display:none;font-size:18px;" Id="emailstar">*</label></td>    
</tr>
<tr><td align="left"><input Id="email" name="email" style="width:515px;"  type="text"></td></tr>
<tr><td height="12px"/></tr>
<tr>
<td align="left"><label for="phone">Phone/Mobile:</label><label style="color:red;font-size:18px;display:none;" Id="phonestar">*</label></td>    
</tr>
<tr><td align="left"><input Id="phone" name="phone" style="width:515px;"  type="text"></td></tr>

<tr><td height="12px"/></tr>
<tr>
<td align="left"><label for="address">Your Address:</label><label style="color:red;font-size:18px;display:none;" Id="addressstar">*</label></td>    
</tr>
<tr><td align="left"><input id="address" name="address" style="width:515px;"  type="text"></td></tr>
<tr><td height="12px"/></tr>
<tr>
<td align="left"><label for="msg">Enter Your Comments / Suggestions / Enquiries</label><label style="color:red;font-size:18px;display:none;" Id="messagestar">*</label></td>    
</tr>
<tr><td align="left"><textarea id="msg" name="msg" style="width:515px;height:100px;"  type="text"></textarea></td></tr>
<tr><td height="12px"/></tr>
<tr>

<td align="right"><table align="left">
<tbody>
  <tr >
<td style="width:160px;"/>
<td style="width:250px;" ><label Id="mandatory" style="display:none;color:red;" >* Mandatory fields</label></td>
<td ><input   type="submit" name="send" value="send" /></td><td >
<input   type="reset" name="reset" value="reset" onclick="resetAll()" /></td></tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T23:26:05+00:00Added an answer on May 19, 2026 at 11:26 pm

    I would move the backend.php script to the top of the page that the form is in. To do this, the form script (“HTML page” as you referred to it) would need to be a .php page rather than a .html page. I’ll assume here that you would call it form.php:

    <?php
    $submitted = false;
    
    if($_POST['msg']) {
        $body = "Name: " . $_POST['name'] .
        "<br>Email: " . $_POST['email'] .
        "<br>Phone/Mobile: " . $_POST['phone'] .
        "<br>Address: " . $_POST['address'] .
        "<br>Message: " . $_POST['msg'];
    
        // Set the $submitted variable to true.  This will let you keep the PHP logic at the top of the page and simply check the value of the variable later to determine whether or not to show a success message.
        if(mail("Info@travelfoodservices.com","Subjects",$body)) $submitted = true;
    }
    ?>
    
    
    <?php
    // Somewhere later on in the page, but above the form, show a success message if the $submitted variable has been set to true.
    if($submitted) echo '<div>The form has been submitted!</div>';
    ?>
    
    <form action="form.php" method="post">
        <!--All the HTML form code goes here-->
    </form>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to find all files in directory? I have HTML page in some directory.
I have an HTML page. I would like to extract all elements whose name
I have a html page that allows users to submit a file. Below is
I made a PHP page that looks up Constant Contact e-mail addresses in a
I have HTML page where windows media player is embedded. It works very well
I have HTML page with some HTML element with ID=logo . I need to
I have an html page that open a popup window when the page loads.
I have an html page with a link like this: <a href=javascript:window.print()>Print QR code</a>
I have an html page called search.html which contains sliders, they work perfectly in
I have an HTML page that contains some filenames that i want to download

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.