It as not easy.
Because your script should work and has not errors I can see.
Well done, for a beginner! 😉
But here is what causes your trouble.
I was just about to give up, when took a look at your HTML FORM inputs.
If you dont get a proper setting of $_POST['submit']
then you get your troubles.
<input type="submit" name"submit" value="Submit"/>
// should be
<input type="submit" name="submit" value="Submit"/>
Also I have modified a few small details.
Among this where $output_form = false;
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>dirthound.com email_sender.php</title>
</head>
<body>
<p><strong>Private:</strong> For web masters use ONLY<br />
Write and send an email to mailing list members.</p>
<?php
$output_form = false;
if (isset($_POST['submit'])) {
$from = 'example@example.com';
$subject = $_POST['subject'];
$text = $_POST['got_dirt_email1'];
if (empty ($subject) && empty ($text)) {
echo 'You forgot the email subject and body text.<br/>';
$output_form=true;
}
if (empty ($subject) && (!empty ($text))) {
echo 'You forgot the email subject.<br/>';
$output_form=true;
}
if ((!empty ($subject)) && empty ($text)) {
echo 'You forgot the email body text.<br/>';
$output_form=true;
}
}
else {
$output_form = true;
}
if ((!empty($subject)) && (!empty($text))) {
$dbc=mysqli_connect ('davedatabase.db.5136595.hostedresource.com',
'******','******','davedatabase')
or die ('Error connecting to MySQL server.');
$query= "SELECT * FROM got_dirt";
$result= mysqli_query ($dbc, $query)
or die(' Error querying database.');
while ($row= mysqli_fetch_array($result)){
$to= $row['email_address'];
$first_name= $row['first_name'];
$last_name= $row['last_name'];
$msg= "Dear $first_name $last_name, \n $text";
mail($to,$subject,$msg,'From:'.$from);
echo 'Email sent to:'.$to. '<br/>';
}// close while
mysqli_close($dbc);
} //close if ((!empty($subject)) && (!empty($text)))
if ($output_form) {
?>
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>" >
<label for="subject">Subject of email:</lable><br/>
<input id="subject" type="text" name="subject" size="60" value="<?php echo $subject; ?>"/><br/>
<label for="got_dirt_email1">Body of email;</label><br/>
<textarea id="got_dirt_email1" name="got_dirt_email1" row="8" cols="60"><?php echo $text; ?></textarea><br/>
<input type="submit" name="submit" value="Submit"/>
</form>
<?php
}
?>
</body>
</html>