created a site for an online newsletter. It was supossed to be just simple. I told the lady i wasn't a programmer at all so not to expect it. Well she wanted a page so someone who is a registered user could send the newsletter to a friend or 5. I found a code on the net that allowed me to do this for one email address. I modified it to allow for the entry of 5 email addresses. My problem now is that when someone enters only one email address and sends it gets an interneal server error:
"Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, and inform them of the time the error occurred, and anything you might have done that may have caused the error.
More information about this error may be available in the server error log."
When you put more than one email address in the field there are no problems and it takes you to the thank you page like it should.
This is the code for the active part of the page:
I deleted most the html table and text so there is just php code
php:<?php
$yname = $_POST['yname'];
$yemail = $_POST['yemail'];
$femail = $_POST['femail'];
$femail2 = $_POST['femail2'];
$femail3 = $_POST['femail3'];
$femail4 = $_POST['femail4'];
$femail5 = $_POST['femail5'];
$comments = $_POST['comments'];
$pageurl = $_GET['loc'];
function outputform() {
$pageurl = $_GET['loc']; ?>
<form method="post" action="../recommend/recommend.php?loc=<?php echo "$pageurl"; ?>">
<td><input type="text" name="yname" id="yname" value="<?php echo "$_POST[yname]"; ?>" />
<td><input type="text" name="yemail" id="yemail" value="<?php echo "$_POST[yemail]"; ?>" />
<td><input type="text" name="femail" id="femail" value="<?php echo "$_POST[femail]"; ?>" />
<td><input type="text" name="femail2" id="femail2" value="<?php echo "$_POST[femail2]"; ?>" />
<td><input type="text" name="femail3" id="femail3" value="<?php echo "$_POST[femail3]"; ?>" />
<td><input type="text" name="femail4" id="femail4" value="<?php echo "$_POST[femail4]"; ?>" />
<td><input type="text" name="femail5" id="femail5" value="<?php echo "$_POST[femail5]"; ?>" />
<td><textarea name="comments" rows="3" id="comments"><?php echo "$_POST[comments]"; ?></textarea>
<td align="center"><input type="submit" id="submit" name="submit" value="Send">
</form>
<?php
}
if ($_POST['submit']) {
if (($yname=="") || ($femail=="")|| ($yemail=="")) {
print "<p><strong>Error:</strong> Please complete all of the required form fields.</p>";
outputform();
}
else {
if (!eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $yemail)) {
print("<p><strong>Error:</strong> your email address is not in a valid format.</p>");
outputform();
exit;
}
if (!eregi("^[a-z0-9]+([-_\.]?[a-z0-9])+@[a-z0-9]+([-_\.]?[a-z0-9])+\.[a-z]{2,4}", $femail)) {
print("<p><strong>Error:</strong> your friend's email address is not in a valid format.</p>");
outputform();
exit;
}
$comments = stripslashes($comments);
mail("$femail","$yname This is where the text of the email is \n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThis message was sent from $sitename ($siteaddress)","From:$yemail");
echo "<p>Thank you, Your recommendation to <strong>$femail</strong> has been sent.</p><p><a href=\"http://www.blah.com\">Go Back</a></p>";
mail("$femail2","$yname This is where the text of the email is \n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThis message was sent from $sitename ($siteaddress)","From:$yemail");
echo "<p>Thank you, Your recommendation to <strong>$femail2</strong> has been sent.</p><p><a href=\"http://www.blah.com\">Go Back</a></p>";
mail("$femail3","$yname This is where the text of the email is\n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThis message was sent from $sitename ($siteaddress)","From:$yemail");
echo "<p>Thank you, Your recommendation to <strong>$femail3</strong> has been sent.</p><p><a href=\"http://www.blah.com\">Go Back</a></p>";
mail("$femail4","$yname This is where the text of the email is\n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThis message was sent from $sitename ($siteaddress)","From:$yemail");
echo "<p>Thank you, Your recommendation to <strong>$femail4</strong> has been sent.</p><p><a href=\"http://www.blah.com\">Go Back</a></p>";
mail("$femail5","$yname This is where the text of the email is \n\n Additional Comments: \n------------------------------------ \n$comments \n------------------------------------\n\nThis message was sent from $sitename ($siteaddress)","From:$yemail");
echo "<p>Thank you, Your recommendation to <strong>$femail5</strong> has been sent.</p><p><a href=\"http://www.blah.com\">Go Back</a></p>";
}
}
else {
?>
<?php
outputform();
}
?>
If anyone can tell me what i am doing wrong here i would appreciate it.
Also please know that i do not know php, i just am savvy enough on computers and coding to be able to decipher and modify (if i'm lucky). I am a computer repair tech and networking specialist and graphic artist by trade.
Thank you
i can be contacted at: abstract@abstract1.com