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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T14:14:52+00:00 2026-06-10T14:14:52+00:00

Here is my PHP mailer code: if ($_POST) { $email=$_POST[’email’]; $subject=$_POST[‘subject’]; $budget=$_POST[‘budget’]; $text=$_POST[‘text’]; $to=hello@mymail.com;

  • 0

Here is my PHP mailer code:

if ($_POST) {
    $email=$_POST['email'];
    $subject=$_POST['subject'];
    $budget=$_POST['budget'];
    $text=$_POST['text'];
    $to="hello@mymail.com";

    mail($to, "Piece of Cake = ".$subject, $text, "Budget:".$budget, "From:".$email );
}

And here is my AJAX email function:

$(function (){
    $('button#send_brief').click(function(){
        var email = $('#brief_email');
        var subject = $('#brief_type');
        var budget = $('#brief_budget');
        var text = $('#brief_comments');
        var emailerData = 'email' + email +'&subject' + subject + '&budget' + budget+ '&text' + text;

        if(text=='') {
            $('#brief_email').css({'background-color':'red'});
         }
         else {

        $.ajax({
            type: "POST",
            url:"emailer.php",
            data: emailerData,
            success: function(){
                $('.success').fadeIn(1000);
                setTimeout (function(){
                $('.brief').slideUp({
                    duration: 1000,
                    easing: 'easeInSine'});}
                            ,2000);
                setTimeout (function(){
                $('#brief').fadeIn();}
                            ,3000);
                setTimeout (function(){
                $('.success').fadeOut(1000);}
                            ,2000);
            }

        });

        return false;}
    });   

});

And here my form:

<form method="POST" action="" >
<fieldset>

            <label for="brief_email">Your email</label>
            <input type="text" id="brief_email" placeholder="your contact email here"/>
             etc ...
</fieldset>
</form>
<button id="send_brief">Send it</button>

First of all when I leave all fields empty, it still show me Success screen. And second of all I don’t get emails, that it sends, even when I enter valid data.

I have reviewed the code many times and seems OK to me.

Please help me find where I am 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-10T14:14:54+00:00Added an answer on June 10, 2026 at 2:14 pm

    your problem is in the AJAX construct, you lack getting value with: val()

    var email = $('#brief_email').val();
    var subject = $('#brief_type').val();
    var budget = $('#brief_budget').val();
    var text = $('#brief_comments').val();
    

    Without val() you will send an object to the PHP script and not a value.

    And vars construct you lack =

    var emailerData = 'email=' + email +'&subject=' + subject + '&budget=' + budget+ '&text=' + text;
    

    Also your mail() construct is bad, you cannot send any other values than it requires check mail(). And you check for $_POST, $_POST is always true, you need to check at least one post value.

    <?php
    
    if (isset($_POST['email'])) {
        $email=$_POST['email'];
        $subject=$_POST['subject'];
        $budget=$_POST['budget'];
        $text=$_POST['text'];
        $to      = 'mail@example.com';
    
        $subject = "Piece of Cake = ".$_POST['subject'];
        $message = "New message from website
    
        Email: $email
        Budget: $budget
        Comments: $text";
    
        $headers = 'From: ' . $email . "\r\n" .
            'Reply-To: ' . $email . "\r\n" .
            'X-Mailer: PHP/' . phpversion();
    
        mail($to, $subject, $message, $headers);
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: PHPMailer AddAddress() Here is my code. require('class.phpmailer.php'); $mail = new PHPMailer(); $email
here is php mailer.php file <?php $to = abc@gmail.com; $subject = Contact via website;
i am posting to a mailer.php file. mailer.php <?php if(isset($_POST['submit'])) { $to = testabc@gmail.com;
For example, my goal is to test the code given here: PHP script that
Here's my php code: <?php if($user->uid == '1'){ ?> <h3 class=info>Upcoming Games</h3> <!--MY CHANGE
Here is my PHP code.. $input = zergling-light $output = str_replace('-', ' (', $input).);
I m using a button inside anchor Here is code <a href=<?php echo $INCLUDE_ROOT_DIRECTORY.
$to= 'somebody@somedomain.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' .
I want to send email using the php code, Following is the code should
Here is my code: class FormValidator { private $firstname; private $lastname; private $email; private

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.