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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:21:02+00:00 2026-06-15T08:21:02+00:00

HTML code: <form class=contact_form action= name=contact_form> <ul><li> <input type=email name=email placeholder=Enter your email here

  • 0

HTML code:

<form class="contact_form" action="" name="contact_form">
<ul><li>
<input type="email" name="email" placeholder="Enter your email here" required />
</li><li>
<button class="submit" type="submit" style="float:left" onclick="form()"onsubmit="hide_form('container_subscribe')">Send</button>
</li></ul>
</form>

jQuery/Ajax code :

$(function() {  
  $(".submit").click(function() {  
    // validate and process form here  
    var field1 = $('input[name=email]').val();
    $.ajax({
        type: "POST",
        url: "mail.php?f1="+field1,
    });
  });  
});

PHP code :

<?php
$to      =  $_POST['field1'];
$subject =  'the subject';
$message =  'hello';
$headers =  'From: webmaster@example.com' . "\r\n" .
               'Reply-To: webmaster@example.com' . "\r\n" .
               'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message, $headers);
?>

The php script is working if I run it alone with $_GET instead of $_POST (the mail is sent) so I think ajax can’t communicate with the php file.
I have no idea how to debug this.

  • 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-15T08:21:04+00:00Added an answer on June 15, 2026 at 8:21 am

    One problem is you are calling the parameter f1 in your AJAX and field1 in your PHP. These need to match.

    You also need to write your AJAX like this

    $.ajax({
        type: "POST",
        data: "f1="+field1,
        url: "mail.php"
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My HTML code: <p>NEWS</p> <p> <form action=news.php method=post> <center><input name=NEW type=submit id=new value=NEW/> <input
I have the following html code: <form> <table> <tbody> <tr> <td> <span>Quantity<span class=pull-right>3</span> <input
In my HTML code, I have a form tag that contains two input boxes,
I have below html code in one of the opensource project. <form action=/wiki/bin/view/Main/Search> <div
When I click - it doesn't do anything. Html code: <fieldset> <form action=# method=post
The code looks like this: html <form action=contact.php method=post enctype=multipart/form-data onsubmit=return Validare();> <input type=text
Here is the code: contact_us2.php <form id=form1 method=post action=enquires.php> <fieldset> <legend>Form to database example</legend>
Here's my updated code trying to get my form to send me the email.
I am trying to echo a result from xml into my html code form
Pls check code .html form gets submitted even if javascript returns false. <form id=form1

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.