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 890431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T13:43:54+00:00 2026-05-15T13:43:54+00:00

I am using jQuery to swap out the image here after the submit button

  • 0

I am using jQuery to swap out the image here after the submit button on an email from is submitted. This part works very well, however, I also need to generate the email from the form contents.

Here is the form:

            <form action="estimate.php" action="post">
                <fieldset>
                <input type="text" name="name" value="FULL NAME" onfocus="if (this.value=='FULL NAME') this.value='';"/>
                <input type="text" name="phone" value="PHONE NUMBER" onfocus="if (this.value=='PHONE NUMBER') this.value='';"/>
                <input type="text" name="email" value="EMAIL" onfocus="if (this.value=='EMAIL') this.value='';"/>
                <input type="text" name="date" value="MOVE DATE" onfocus="if (this.value=='MOVE DATE') this.value='';"/>
                <input type="text" name="origin" value="ORIGINATING ADDRESS" onfocus="if (this.value=='ORIGINATING ADDRESS') this.value='';"/>
                <input type="text" name="destination" value="DESTINATION ADDRESS" onfocus="if (this.value=='DESTINATION ADDRESS') this.value='';"/>
                <select name="move-type">
                    <option value="" selected="selected">TYPE OF MOVE</option>
                    <option value="Private">Private</option>
                    <option value="Commercial">Commercial</option>
                </select>
                <input id="quoteSubmit" 
                    type="image" src="_images/btn_submit.png" alt="" 
                    onmouseover="javascript:this.src='_images/btn_submit-over.png'" 
                    onmouseout="javascript:this.src='_images/btn_submit.png'"/>
                </fieldset>
            </form>

Here is the jQuery:

        // free quote form
    $('#freeQuote form').submit(function(e){

    //Set the data ready for ajax post
    var formdata = $(this).serialize();

    $.post("estimate.php",formdata,function(data){
        if(data.error)
        {
           alert('Error: ' + data.error);
           return;
        }
    });

    //The Image
    var Image = $('<img />').attr({src:'_images/free-quote-confirm.png', width:231, height:267, alt:"Success"});

    //Remove the form
    $('#freeQuote form').remove()

    //Add the image inside the div
    $('#freeQuote').append(Image);

    //Return false so the form does not send as normal. you can also use e.PreventDefault():
    return false;
});

Here is the PHP:

<?php # sends contents of  Free Estimate form

if (isset($_POST['submitted'])) {
$errors = array();

// Check for empty fields

if (empty($_POST['name'])) {
    $errors[] = 'Please enter your name.';
} 

if (empty($_POST['email'])) {
    $errors[] = 'Please enter your email address.';
} 

if (empty($_POST['date'])) {
    $errors[] = 'Please enter the date of your move.';
} 

if (empty($_POST['origin'])) {
    $errors[] = 'Please enter the origin of your move.';
} 

if (empty($_POST['destination'])) {
    $errors[] = 'Please enter the destination.';
} 

if (empty($errors)) { // everything is okay

$body = "The following Free Estimate Request has been submitted:\n

    Submitted by: {$_POST['name']}\r
    E-mail: {$_POST['email']}\r
    Phone: {$_POST['phone']}\r
    Move date {$_POST['date']}\r
    Moving from: {$_POST['origin']}\r
    Moving to: {$_POST['destination']}\r
    Move type: {$_POST['move-type']}\r;

    mail ('forrest@rouviere.com', 'Free Estimate Request', $body, 'From: admin@movingsimplified.com');      

    // end email

} else {    
    echo '<h2>Error!</h2>
    <p class="errors">The following error(s) occurred:<br />';
    foreach ($errors as $msg) {
        echo " - $msg<br />\n";
    }
    echo '</p><p>Please go back and try again.</p><p><br /></p>';
}
};

?>

The basic problem is, I can click the submit button without anything entered in the fields, and I don’t get an email.

Any help would be appreciated.

Thanks.

  • 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-15T13:43:54+00:00Added an answer on May 15, 2026 at 1:43 pm

    Unless your code snipper is in correct you have the following issue..

    $body = " // there is no closing "
    

    You also state in your question:

    The basic problem is, I can click the submit button without anything entered in the fields, and I don’t get an email.

    Your example would suggest (if no syntax errors) that you don’t want an email sent if there are errors.

    New corrected request.php

    <?php # sends contents of  Free Estimate form
    
    if (isset($_POST['submitted'])) {
        $errors = array();
    
        // Check for empty fields
    
        $checkArray = array('name', 'email', 'date', 'origin', 'destination');
        foreach($checkArray as $check) {
            if (empty($_POST[$check])) {
                $errors[] = 'Please enter your '.$check;
            } 
        }
    
        if (empty($errors)) { // everything is okay
    
            $body = "The following Free Estimate Request has been submitted:\n
    
                Submitted by: {$_POST['name']}\r
                E-mail: {$_POST['email']}\r
                Phone: {$_POST['phone']}\r
                Move date {$_POST['date']}\r
                Moving from: {$_POST['origin']}\r
                Moving to: {$_POST['destination']}\r
                Move type: {$_POST['move-type']}\r;
    
            ";
    
            mail ($to, 'Free Estimate Request', $body, 'From:  '.$from);      
    
            // end email
    
        } else {    
            // If error then NO Email sent
            echo '<h2>Error!</h2>
            <p class="errors">The following error(s) occurred:<br />';
            foreach ($errors as $msg) {
                echo " - $msg<br />\n";
            }
            echo '</p><p>Please go back and try again.</p><p><br /></p>';
        }
    };
    
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 475k
  • Answers 475k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer if you change your mind and want a GUI app… May 16, 2026 at 4:34 am
  • Editorial Team
    Editorial Team added an answer It's because you haven't constrained it to match the entire… May 16, 2026 at 4:34 am
  • Editorial Team
    Editorial Team added an answer SELECT * FROM Table2 WHERE tID IN (SELECT Table2.tID FROM… May 16, 2026 at 4:34 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.