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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:53:06+00:00 2026-05-28T03:53:06+00:00

Looks like send.php is being accessed and sending blank emails. Need to make it

  • 0

Looks like send.php is being accessed and sending blank emails. Need to make it so send.php doesn’t send email, unless the submit button is used on a form. I was told ‘isset $_post’ would help me, just not clear on how to execute it.

Here’s send.php code:

    <?php

$recipient  =   'test@test.com';

$email      =   $_REQUEST['Email'];

$subject    =   'Contact Form Submission';

$content    =   "The following has been submitted on your website \n\n";

$redirect   =   'thankyoupage.html';

$user = $_REQUEST['Email'];
$usersubject = "Subject";
$userheaders = "From: test@test.com\n";
$usermessage = "Blah blah blah";
mail($to,$subject,$message,$headers);
mail($user,$usersubject,$usermessage,$userheaders);

foreach($_POST as $k=>$v)
    {
        $content .= "$k: $v\n\n";
    }

mail_it(stripslashes($content), $subject, $email, $recipient);

if (isset($_POST['redirect']))
    {
        header("Location:".$_POST['redirect']);
    }
        else
    {
        header("Location: $redirect");
    }

function mail_it($content, $subject, $email, $recipient)
    {

        $headers .= "From: ".$email."\n";
        $headers .= "Reply-To: ".$email."\n";

        if ($bcc) $headers .= "Bcc: ".$bcc."\n"; 

        $headers .= "X-Priority: 0\n";
        $headers .= "X-Mailer: bjm Formmail \n";
        $message = $content."\n\n";

        if( !mail($recipient, $subject, $message, $headers))
        {
            echo "Sorry - an error occured trying to send the mail";
        }

    }

?>
  • 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-28T03:53:07+00:00Added an answer on May 28, 2026 at 3:53 am

    You have to check wether the request method was POST. If so, you should send the email:

    <?php
    
    $recipient  =   'test@test.com';
    
    $email      =   $_REQUEST['Email'];
    
    $subject    =   'Contact Form Submission';
    
    $content    =   "The following has been submitted on your website \n\n";
    
    $redirect   =   'thankyoupage.html';
    
    $user = $_REQUEST['Email'];
    $usersubject = "Subject";
    $userheaders = "From: test@test.com\n";
    $usermessage = "Blah blah blah";
    
    
    foreach($_POST as $k=>$v)
        {
            $content .= "$k: $v\n\n";
        }
    
    if($_SERVER["REQUEST_METHOD"] == "POST") {
         mail_it(stripslashes($content), $subject, $email, $recipient);
    }
    
    if (isset($_POST['redirect']))
        {
            header("Location:".$_POST['redirect']);
        }
            else
        {
            header("Location: $redirect");
        }
    
    function mail_it($content, $subject, $email, $recipient)
        {
    
            $headers .= "From: ".$email."\n";
            $headers .= "Reply-To: ".$email."\n";
    
            if ($bcc) $headers .= "Bcc: ".$bcc."\n"; 
    
            $headers .= "X-Priority: 0\n";
            $headers .= "X-Mailer: bjm Formmail \n";
            $message = $content."\n\n";
    
            if( !mail($recipient, $subject, $message, $headers))
            {
                echo "Sorry - an error occured trying to send the mail";
            }
    
        }
    
    ?>
    

    This makes it all happen:

    if($_SERVER["REQUEST_METHOD"] == "POST") {
         mail_it(stripslashes($content), $subject, $email, $recipient);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have problem to send value from php to jQuery script. PHP looks like
I would like to send data using $.ajax like this: $.ajax({'url': 'my.php', 'type': 'POST',
First, here is what my current system looks like: CouchDB 1.0.2 PHP 5.3.6 Apache
I am trying to send an email via PHP mail() with attachments. The attachments
I am trying to send in PHP an HTML email but it always shows
I'm running PHP under Apache and I'd like to send a slow trickle of
Looks like here in StackOveflow there is a group of F# enthusiasts. I'd like
Looks like my only option is to create a mutatant child of the tree
Looks like while( condition ) { //do stuff } is completely equivalent to for(
Looks like ExpressionTrees compiler should be near with the C# spec in many behaviors,

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.