FWDrew
12-13-2008, 11:47 PM
Hi everyone,
Im having a small issue with what should be a simple mailing script. Here is the relevant code, that is returning a 500 server error when submitted:
Form:
<form action="send.php" method="post">
<p>Subject:</p>
<p><input type="text" name="subject" /></p>
<p>Mail Body:</p>
<p><textarea rows="10" cols="40" name="body"></textarea></p>
<p><input type="submit" name="submitMail" value="Send" /></p>
</form>
send.php
<?php require('conn.php');?>
<?php
if($_SESSION['loggedIn'] != 'LOGGEDIN') {
header('Location:index.php');
}
elseif($_POST['submitMail'] && !empty($_POST['subject']) && !empty($_POST['body'])) {
$subject = strip_tags($_POST['subject']);
$body = strip_tags($_POST['body'], '<p><a><b><i><quote>');
$mailHeaders = 'Email Newsletter';
//Setup query
$result = mysql_query("SELECT email FROM subscribers") or die(mysql_error());
while(mysql_fetch_array($result)){
$email = $row['email'];
mail($email, $subject, $body, $mailHeaders);
echo "<p>Email sent to the address of " .$row['email']. ".</p>";
}
mysql_free_result($result);
mysql_close($connection);
}
else {
header('Location:index.php');
}
?>
in case you need it here is conn.php but I am not getting any mysql errors:
<?php
session_start();
$host = "xxxxxxxxxx";
$user = "xxxxxxxxxx";
$pass = "xxxxxxxxxx";
$db = "xxxxxxxxx";
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect to database!");
mysql_select_db($db) or die ("Unable to select database!");
?>
There are no reasons given with the 500 server error, just to contact the server administrator, any ideas?
Thanks much,
Drew
Im having a small issue with what should be a simple mailing script. Here is the relevant code, that is returning a 500 server error when submitted:
Form:
<form action="send.php" method="post">
<p>Subject:</p>
<p><input type="text" name="subject" /></p>
<p>Mail Body:</p>
<p><textarea rows="10" cols="40" name="body"></textarea></p>
<p><input type="submit" name="submitMail" value="Send" /></p>
</form>
send.php
<?php require('conn.php');?>
<?php
if($_SESSION['loggedIn'] != 'LOGGEDIN') {
header('Location:index.php');
}
elseif($_POST['submitMail'] && !empty($_POST['subject']) && !empty($_POST['body'])) {
$subject = strip_tags($_POST['subject']);
$body = strip_tags($_POST['body'], '<p><a><b><i><quote>');
$mailHeaders = 'Email Newsletter';
//Setup query
$result = mysql_query("SELECT email FROM subscribers") or die(mysql_error());
while(mysql_fetch_array($result)){
$email = $row['email'];
mail($email, $subject, $body, $mailHeaders);
echo "<p>Email sent to the address of " .$row['email']. ".</p>";
}
mysql_free_result($result);
mysql_close($connection);
}
else {
header('Location:index.php');
}
?>
in case you need it here is conn.php but I am not getting any mysql errors:
<?php
session_start();
$host = "xxxxxxxxxx";
$user = "xxxxxxxxxx";
$pass = "xxxxxxxxxx";
$db = "xxxxxxxxx";
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect to database!");
mysql_select_db($db) or die ("Unable to select database!");
?>
There are no reasons given with the 500 server error, just to contact the server administrator, any ideas?
Thanks much,
Drew