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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:22:35+00:00 2026-06-04T04:22:35+00:00

When a user press submit button I received 7 copies duplicate mail in my

  • 0

When a user press submit button I received 7 copies duplicate mail in my administrator email box. How can I receive only one mail. here is my code.

$MyCoupon = 0;
$cResult=mysql_query("select * from codes WHERE status='active'");
while($cRow = mysql_fetch_assoc($cResult)){
    if($_POST['coupon_used']==$cRow['code'] || $_POST['invoice']=="invoice"){

            $coupon = ($_POST['coupon_used']!="" ? $_POST['coupon_used'] : "invoice");

            $aRes = mysql_query("SELECT * FROM `adverts` WHERE `ad_id`='".$_POST['ad_id']."'");
            $aRow = mysql_fetch_assoc($aRes);

            $updateQuery = "UPDATE `adverts` SET `message_status`='awaiting approval',`target_impressions`='".$_POST['ad_impressions']."',`recurring`='".$_POST['ad_recurring']."',`coupon_used`='".$coupon."',`POIO`='".$_POST['ad_POIO']."' WHERE `ad_id`='".$_POST['ad_id']."'";         
            $updateResult=mysql_query($updateQuery) or die("Unexpected error: record could not be added.".mysql_error());
            include_once("update_ads_from_database.php");

            //SEND EMAIL to CC
                $to = "mymail@gmail.com";
            $headers = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            $headers .= 'From: Do-Not-Reply@domain.com';
            $subject = 'New self-serve mail';
            $message = "The following self-service ad has just been submitted:<br>";
            $message .= $aRow['contact_name']."<br>".$aRow['contact_phone']."<br>".$aRow['contact_email'];
            $message .= "<br><br>Description:".$aRow['description']."<br>Content:".stripslashes($aRow['value'])."<br><br>";
            $message .= "Click <a href=\"http://www.domain.com/admin/approve_self_ad.php\">here</a> to approve it.";
            mail($to,$subject,$message,$headers);
            $goodCoupon++;
  • 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-04T04:22:36+00:00Added an answer on June 4, 2026 at 4:22 am

    You are sending one email for each coupon code found on the database. You could create a single email message, and send it after the loop:

    $MyCoupon = 0;
    // Init empty message body
    $message = "";
    $cResult=mysql_query("select * from codes WHERE status='active'");
    while($cRow = mysql_fetch_assoc($cResult)){
        if($_POST['coupon_used']==$cRow['code'] || $_POST['invoice']=="invoice"){
            $coupon = ($_POST['coupon_used']!="" ? $_POST['coupon_used'] : "invoice");
            $aRes = mysql_query("SELECT * FROM `adverts` WHERE `ad_id`='".$_POST['ad_id']."'");
            $aRow = mysql_fetch_assoc($aRes);
            $updateQuery = "UPDATE `adverts` SET `message_status`='awaiting approval',`target_impressions`='".$_POST['ad_impressions']."',`recurring`='".$_POST['ad_recurring']."',`coupon_used`='".$coupon."',`POIO`='".$_POST['ad_POIO']."' WHERE `ad_id`='".$_POST['ad_id']."'";        
            $updateResult=mysql_query($updateQuery) or die("Unexpected error: record could not be added.".mysql_error());
            include_once("update_ads_from_database.php");
    
            // Add info on current row to email body
            $message .= "The following self-service ad has just been submitted:<br>";
            $message .= $aRow['contact_name']."<br>".$aRow['contact_phone']."<br>".$aRow['contact_email'];
            $message .= "<br><br>Description:".$aRow['description']."<br>Content:".stripslashes($aRow['value'])."<br><br>";
            $message .= "Click <a href=\"http://www.domain.com/admin/approve_self_ad.php\">here</a> to approve it.";
    
            $goodCoupon++;
        } // end if
    } // end while
    
    //SEND EMAIL to CC
    $to = "mymail@gmail.com";
    $headers = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    $headers .= 'From: Do-Not-Reply@domain.com';
    $subject = 'New self-serve mail';
    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

I have a form with a disabled submit button. Even though the user can't
I want to send a user feedback form through email. when they press submit
Is there anyway I can submit a form without a submit button, but only
In my application, I'm trying to make it so the User can press a
When my user press Enter on the virtual android user validate entry! keyboard my
I have a console program and I want if the user press ctrl-z the
Is there anyway to close iphone app just like user press the menu key?
I have an activity with two buttons, start and stop. If the user press
When you press the JButton Ny the user input is supposed to be added
I have an activity that lets the user load some data when they press

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.