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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:18:38+00:00 2026-06-12T08:18:38+00:00

I have asked before for help to get my php form working inside an

  • 0

I have asked before for help to get my php form working inside an phonegap ipa. I did exactly as I was told and everything works just fine, even inside the ipa. Only problem I have is that I get this alert right at the moment when the page loads, obviously it should show up when client forgets to fill in a required field.

Here is what I did:

FORM in contact.html

 <form action="http://mobile.alicante-intermedia.com/submit_contact.php" method="get">
          <div class="form-element">
        <label for="txtfullname">Firstname</label>
        <input id="txtfullname" name="FirstName" type="text" placeholder="required" required />
      </div>
      <div class="form-element">
        <label for="txtemail">Lastname</label>
        <input id="txtemail" name="LastName" type="text" placeholder="required" required  />
      </div>
      <div class="form-element">
        <label for="txtcontact">Email</label>
        <input id="txtcontact" name="Email" type="email" placeholder="optional" />
      </div>
      <div class="form-element">
        <label for="txtmessage">Message</label>
        <textarea id="txtmessage" name="MessageText" placeholder="required" rows="5" required ></textarea>
      </div>
      <input type="button" onclick="submit()" value="submit contact"/>
      </form>

Then I created a jquery_form.js file which loads only inside the conatct.html

$.post('http://mobile.alicante-intermedia.com/submit_contact.php', {

    // These are the names of the form values

    FirstName: $('#FirstName_input').val(),
    LastName: $('#LastName_input').val(),
    Email: $('#Email_input').val(),
    MessageText: $('#MessageText_input').val()

    // HTML function

    }, function (html) {
        // Place the HTML in a astring
        var response=html;

        // PHP was done and email sent
        if (response=="success") {
            alert("Message sent!"); 
        } else {

            // Error postback
            alert("Please fill all fields!"); 
        return false;
    }
});

And the php looks like this:

<?php

    // VARS
    $FirstName=$_GET["FirstName"];
    $LastName=$_GET["LastName"];
    $Email=$_GET["Email"];
    $MessageText=$_GET["MessageText"];
    $Headers = "From:" . $Email;

    //VALIDATION
    if(
    $FirstName=="" ||
    $LastName=="" ||
    $Email=="" ||
    $MessageText==""
    ) {
        echo "Error";
    } else {
        mail("myemail@email.com","mobile app message",$MessageText, $Headers);
        echo "Success";
    }
?>

Everything works fine except the alert screen. Anyone here who has an idea what went wrong?

  • 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-06-12T08:18:40+00:00Added an answer on June 12, 2026 at 8:18 am

    Your JavaScript code is “bare”, not wrapped in any function or attached to any event handler, and therefore executes as soon as it is loaded – so it immediately posts an empty form when the jQuery script is first parsed.

    Place it into the onclick event handler for the submit button:

    // When the document has loaded...
    $(document).ready(function() {
      // Bind this action as a function to be executed when the button is clicked...
      $('input[type="button"][value="submit contact"]').click(function() {
        $.post('http://mobile.alicante-intermedia.com/submit_contact.php', {
    
          // These are the names of the form values
          // EDIT: You have the wrong ids on these...
    
          FirstName: $('#txtfullname').val(),
          LastName: $('#txtemail').val(),
          Email: $('#txtcontact').val(),
          MessageText: $('#txtmessage').val()
    
          // HTML function
    
          }, function (html) {
              // Place the HTML in a astring
              var response=html;
    
              // PHP was done and email sent
              if (response=="success") {
                alert("Message sent!"); 
              } else {
    
                // Error postback
                alert("Please fill all fields!"); 
                return false;
              }
        });
      });
    });
    

    Since it is bound in the JavaScript code, remove the onclick from the button in your markup:

    <input type="button" value="submit contact"/>
    

    Edit:

    The PHP you have is looking for values in $_GET, but you have posted them from jQuery. Look instead in $_POST.

    $FirstName=$_POST["FirstName"];
    $LastName=$_POST["LastName"];
    $Email=$_POST["Email"];
    $MessageText=$_POST["MessageText"];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have asked this before but I didn't get the question right so the
Questions exactly like this have been asked before, i've read them all and tried
I know that this question is being asked before but I did not get
This question may have been asked before, but I had trouble finding an answer,
similar questions have been asked before but I cant find an exact match to
This seems to have been asked before: rails decimal precision and scale But when
This has / may have been asked before, but, as far as I remember,
I know similiar questions have been asked before, but please bear with me as
I know similar questions have been asked before, but I've tried many times and
I think it might have been asked before but i was unable to find

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.