Ok here's the HTML source. It validates on BBEdit without problems.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Newsletter</title>
</head>
<body>
<table cellpadding="10" cellspacing="10" border="0" width="100%">
<tr valign="top">
<td align="center"><form action="newsletter.php" method="post">
<table cellpadding="5" cellspacing="0" border="0">
<tr valign="top">
<td align="right">Newsletter Text:</td>
<td><textarea name="newsletter" rows="15" cols="70">Default Text</textarea></td>
</tr>
</table>
<br /><br />
<span class="titletext">There are 482 subscribers to the newsletter<br /><br /></span>
<input type="submit" name="submit" value="Send Newsletter" />
</form></td>
</tr>
<tr valign="top">
<td align="center"><a href="index.html">Back to menu</a></td>
</tr>
</table>
</body>
</html>
[/COLOR]
And the PHP below (this is called newsletter.php).
<?
include("dbfunctions.inc");
// db functions contains mysql_connect and mysql_select_db
function safe_query ($query = "") {
if (empty($query)) { return FALSE; }
$result = mysql_query($query)
or die("Query failed: "
."<li>errorno=".mysql_errno() . "</li>"
."<li>error=".mysql_error() ."</li>"
."<li>query=".$query . "</li>"
."Please contact the webmaster"
);
return $result;
}
$default_text = "DEFAULT TEXT";
// Only run this if the submit button clicked
if (isset($submit) AND $submit == "Send Newsletter") {
// Only run if the text area doesn't contain the default text
if (strpos($_POST['newsletter'], "DEFAULT TEXT") === FALSE) {
// Only select those from the database that agreed to mailings.
$query = "SELECT email, first_name, surname FROM userlist WHERE newsletter = 'y'";
$result = safe_query($query);
if (!empty($_POST['newsletter'])) {
while ($row = mysql_fetch_array($result,MYSQL_ASSOC)) {
$mailstring = stripslashes(strip_tags(trim($default_text)));
$mailto = "{$row['first_name']} {$row['surname']} <{$row['email']}>";
mail($mailto,"Newsletter",$mailstring,"From: Newsletter <newsletter@REMOVED.com>\r \n");
}
$output_message = "<span class=\"warningtext\">Newsletter sent</span>";
}
}
}
$query = "SELECT * FROM userlist WHERE newsletter = 'y'";
$result = safe_query($query);
$num_rows = mysql_num_rows($result);
// $num_rows contains total number of subscribers
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Newsletter</title>
</head>
<body>
<table cellpadding="10" cellspacing="10" border="0" width="100%">
<?
if (!empty($output_message)) {
echo "<tr valign=\"top\">\n" .
"<td><span class=\"titletext\">{$output_message}</span></td>\n" .
"</tr>\n\n";
}
?>
<tr valign="top">
<td align="center"><form action="newsletter.php" method="post">
<table cellpadding="5" cellspacing="0" border="0">
<tr valign="top">
<td align="right">Newsletter Text:</td>
<td><textarea name="newsletter" rows="15" cols="70"><?= $default_text; ?></textarea></td>
</tr>
</table>
<br /><br />
<span class="titletext">There are <?= $num_rows; ?> subscribers to the newsletter<br /><br /></span>
<input type="submit" name="submit" value="Send Newsletter" />
</form></td>
</tr>
<tr valign="top">
<td align="center"><a href="index.html">Back to menu</a></td>
</tr>
</table>
</body>
</html>
This page is playing up (i've had to remove some text from it such as my database user name & password!) and other pages I have written have all been fine. This occured on one other page which I cured by adding a hidden field. That page was a simple one field form asking for a user to confirm their password.
However this still creates the error. It works fine for short amounts of text, but if you try sending long text (i've tested with the lorem ipsum text) the text "newsletter=...." appears in the variable value (checked by print_r($_POST['newsletter'])😉