I am at my wits end. I have this code (posted below) with a send email button, which is in theory supposed to send just that page. The problem, that i can't resolve, is that is sends an email for each entry. So when I click the submit button i get like 20 emails. The first email has the 1 entry, 2nd has 2 entries, so on and so forth. Can anyone help resolve this, my eyes are bleeding at this point. -
<?
-
require("format.php");
-
echo $format;
-
-
?>
-
-
-
</div>
-
-
-
-
-
-
-
-
-
-
<div id="main"> <a name="TemplateInfo"></a>
-
<h1></h1>
-
<?
-
include_once("format.php");
-
echo $format;
-
-
-
?>
-
-
<?
-
include_once('sql_connect.php');
-
include_once('shared_sql.php');
-
include_once('submittedby.php');
-
-
-
$Report_Date = date("Y-m-d H:i");
-
-
-
$Title = "<H2>Weekly Action Items</H2>";
-
-
//query todo report
-
$query1 = ("SELECT * FROM todo WHERE (Status <> 'closed') ORDER BY SubmittedBy ASC");
-
-
-
$mail_form = "
-
<form method='post' action='index.php'>
-
<input type='hidden' name='report' value=\"$Current_Shift_Report\">
-
<input type='text' name='email' value='xxx@xxx.com' size='55'>
-
<input type='submit' name='submit' value='Send Report'>
-
</form>";
-
-
-
-
-
////////// Start Action Items ////////////
-
-
-
$Production_Control = "<H4>Data Center Action Items</h4>";
-
While (list($Time, $Event, $Action, $TimeofLastUpdate, $Status, $SubmittedBy, $Item) = mysql_fetch_row($result1))
-
{
-
$Production_Control = $Production_Control. "
-
<table rows='4' cols='4' border='1' width='650px'>
-
<tr><td colspan='4' bgcolor='#7CFC00' valign='top'>
-
To Do Entered On: $Time, Submitted by $SubmittedBy, Status=$Status
-
</td></tr>
-
<tr><td colspan='2' valign='top'>
-
</td><td colspan='2' valign='top'>
-
-
</td></tr>
-
<tr><td colspan='2' valign='top'>
-
<u>Event:</u> <br />
-
$Event
-
</td><td colspan='2' valign='top'>
-
<u>Action:</u> <br />
-
$Action
-
</td></tr>
-
<tr><td colspan='4' valign='top'>
-
-
-
-
-
<form action='edit_todo.php' method='post'>
-
<input type='hidden' name='Item' value='$Item'>
-
<input type='submit' value='Update'>
-
</form>
-
</td></tr></table>";
-
-
-
$Current_Shift_Report = "<html><body><h2>$Title</h2>" . $Production_Control . "</body></html>";
-
-
if (isset($_POST['submit']))
-
{
-
-
-
$headers = "From:xxx@xx.com\r\n";
-
$headers .= "Reply-To:xxx@xxx.com\r\n";
-
$headers .= "Content-Type: text/html;\r\n charset=\"iso-8859-1\"\r\n";
-
-
-
-
$email = $_POST['email'];
-
mail("$email", "$Report_Date Action Items",
-
$Current_Shift_Report, $headers);
-
-
-
-
-
-
-
-
-
-
if(!mail)
-
{
-
echo "Your submission failed, please try again later";
-
}
-
-
-
-
-
}
-
}
-
-
-
-
// Print Content //
-
echo "<div id='content'>"
-
.$mail_form
-
.$todoHead
-
.$Production_Control
-
-
."</div>";
-
-
-
-
echo "";
-
-
?>
-
4 1351
Your code to send the email is in your while loop.
So while you are fetching the data from your mysql query, you are sending an email every time you fetch a row.
Oh thank you lord. All fixed. I knew fresh eyes would fix the issue, thanks again
At least I got it down to just 2 emails. Can someone point out the error that is giving me multiple emails this time -
<?
-
require("format.php");
-
echo $format;
-
-
?>
-
-
-
</div>
-
-
-
-
-
-
-
-
-
-
<div id="main"> <a name="TemplateInfo"></a>
-
<h1></h1>
-
<?
-
include_once("format.php");
-
echo $format;
-
-
-
?>
-
-
<?
-
include_once('sql_connect.php');
-
include_once('shared_sql.php');
-
include_once('submittedby.php');
-
-
-
//query todo report
-
$query1 = ("SELECT * FROM todo WHERE (Status <> 'closed') ORDER BY SubmittedBy ASC");
-
-
-
////////// Start Action Items ////////////
-
-
-
$Production_Control = "<H4>Data Center Action Items</h4>";
-
While (list($Time, $Event, $Action, $TimeofLastUpdate, $Status, $SubmittedBy, $Item) = mysql_fetch_row($result1))
-
{
-
$Production_Control = $Production_Control. "
-
<table rows='4' cols='4' border='1' width='650px'>
-
<tr><td colspan='4' bgcolor='#7CFC00' valign='top'>
-
To Do Entered On: $Time, Submitted by $SubmittedBy, Status=$Status
-
</td></tr>
-
<tr><td colspan='2' valign='top'>
-
</td><td colspan='2' valign='top'>
-
-
</td></tr>
-
<tr><td colspan='2' valign='top'>
-
<u>Event:</u> <br />
-
$Event
-
</td><td colspan='2' valign='top'>
-
<u>Action:</u> <br />
-
$Action
-
</td></tr>
-
<tr><td colspan='4' valign='top'>
-
-
-
<form action='edit_todo.php' method='post'>
-
<input type='hidden' name='Item' value='$Item'>
-
<input type='submit' value='Update'>
-
</form>
-
</td></tr></table>";
-
-
$mail_form = "
-
<form method='post' action='index.php'>
-
<input type='hidden' name='report' value=\"$Current_Shift_Report\">
-
<input type='text' name='email' value='xxx@xxx.com' size='55'>
-
<input type='submit' name='submit' value='Send Report'>
-
</form>";
-
-
-
}
-
-
// Print Content //
-
echo "<div id='content'>"
-
.$Production_Control
-
.$mail_form
-
."</div>";
-
-
-
echo "</body></html>";
-
-
-
-
?>
-
-
<?
-
$Report_Date = date("Y-m-d H:i");
-
$Title = "<H2>Weekly Action Items</H2>";
-
-
-
-
-
-
$Current_Shift_Report = "<html><body><h2>$Title</h2>". $Production_Control ."</body></html>";
-
-
-
if (isset($_POST['submit']))
-
{
-
-
-
-
-
$headers = "From:xxx@xxx.com\r\n";
-
$headers .= "Reply-To:xxx@xxx.com\r\n";
-
$headers .= "Content-Type: text/html;\r\n charset=\"iso-8859-1\"\r\n";
-
-
-
-
$email = $_POST['email'];
-
mail("$email", "$Report_Date Action Items",
-
$Current_Shift_Report, $headers);
-
-
-
if(!mail)
-
{
-
echo "Your submission failed, please try again later";
-
}
-
-
}
-
-
-
?>
-
-
$email = $_POST['email'];
-
mail("$email", "$Report_Date Action Items",
-
$Current_Shift_Report, $headers);
-
-
-
if(!mail)
-
{
-
echo "Your submission failed, please try again later";
-
}
-
Try: -
$email = $_POST['email'];
-
$sendmail = mail("$email", "$Report_Date Action Items",
-
$Current_Shift_Report, $headers);
-
-
-
if(!$sendmail)
-
{
-
echo "Your submission failed, please try again later";
-
}
-
Sign in to post your reply or Sign up for a free account.
Similar topics
by: James Hong |
last post by:
Help please, I try to sending an email from my html page using the java
applet.
but it give error on most of the PC only very few work, what is the error i
make
the java applet show as below
...
|
by: dmiller23462 |
last post by:
Here is the code, it's not complete of course....I've been inserting
lines as I go to pinpoint the issue.....I understand that the error
message I'm getting (#185 Missing Default Property) is...
|
by: YZK |
last post by:
Hello. I'm not a Web developer, just a user, and I think I may have
somehow messed myself up majorly. I'm not quite sure how. Right now,
javascript used by websites I go to either does not work at...
|
by: baustin75 |
last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie
only when debugging in php designer 2005
--------------------------------------------------------------------------------
...
|
by: tyler_durden |
last post by:
thanks a lot for all your help..I'm really appreciated...
with all the help I've been getting in forums I've been able to continue
my program and it's almost done, but I'm having a big problem that...
|
by: Sandy |
last post by:
Hello -
I am attempting to email error messages to myself in the event of an error.
I am using the following code:
Dim mail as New MailMessage()
Dim ErrorMessage = "The error description is...
|
by: shror |
last post by:
Hi every body,
Please I need your help solving my php mail() function problem that
the code is appearing in the view source and I dont know whats the
problem where I am using another page tto test...
|
by: ibid |
last post by:
hi every one just wondering if anyone could help sorry if i seem abit dumb but im a newbie to it all
ive got to asign a mail program on my auction site in the config.pl files (i think this is the...
|
by: maxxxxel |
last post by:
Hi
Can anyone help me with some asp code , I changed the code to use CDO.message instead of the old cdont.sys to send mail from a ASP webpage which works fine.
Our problem is that when we send...
|
by: jambonjamasb |
last post by:
Hi
I have two tables:
email_tbl
Data_table
Data table is is used to create a Form
Data_form
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |