Well I put the following together, but when I submit the form, it just refreshes the page and doesn't show the emails the mailer was to be sent to. And it doesn't send the emails.
Anyone see anything wrong with this script?
<?php
include_once('/usr/home/fss/websites/fivestarsports.net/inc/func.inc.php');
if ($_POST[op] != "send"){
//haven't seen the form, so show it
echo"
<html>
<head>
<title>Five Star Mailer</title>
</head>
<body>
<h1>Send A Newsletter</h1>
<form method=\"post\" action=\"$_SERVER[PHP_SELF]\">
<p><strong>Subject:</strong><br>
<input type=\"text\" name=\"subject\" size=30></p>
<p><strong>Mail Body:</strong><br>
<textarea name=\"message\" cols=50 rows=10 wrap=virtual></textarea>
<input type=\"hidden\" name=\"op\" vallue=\"send\">
<p><input type=\"submit\" name=\"submit\" value=\"Send It\"></p>
</form>
</body>
</html>";
}else if ($_POST[op] =="send") {
//want to send form, so check for required fields
if (($_POST[subject] =="") || ($_POST[message] =="")){
header("Location: mailer.php");
exit;
}
//connect to db
$db_conn = five_connect_db();
mysql_select_db('fivestar',$db_conn);
//get emails from mailer_test table
$sql = "SELECT email FROM mailer_test";
$result = mysql_query($sql,$db_conn) or die(mysql_error());
//create a From:mailheader
$headers = "From: <webmaster@fivestarsports.com>";
//loop through results and send mail
while ($row = mysql_fetch_array($result)){
set_time_limit(0);
$email = $row['email'];
mail("$email", stripslashes($_POST[subject]),
stripslashes($_POST[message]),$headers);
echo "newsletter sent to: $email<br>";
}
}
?>