I have this script that I found on the internet:
I'm trying to change it so that I can use it on a church youth page that
I'm working on to allow sunday school teachers to be able to send me their Devotionals for a
database that I have already set up. I need to make it so that the friend's name and friend's mail are non existant.
I want it to send me an email with the person's name, Email, and Devotional.
The page is at www.mikestermedia.com/youth.curtisbaptist.org/add_devotional.php
<html>
<head>
<title>Add a Devotional</title>
</head>
<h2 align="left">Add a Devotional</h2>
<!-- Put headers above here -->
<?php
//The color of the highlight around forgotten fields
$embordercolor = "#ff0000";
if($email&&$name&&$sendname&&$sendemail) {
$body = "You need to add a new devotion to the Database that $name at $email has sent you. ";
$body .= "This is the devotion: " . $devotional;
$thesubject = "New devotion";
if(
mail($sendemail,
$thesubject,
$body,
"From: " . trim($name) . "<address>\n")) {
echo "<BR><BR>Your e-mail was sent successfully.";
} //end if
else {
echo "Sorry, your devotional was not sent successfully please try again<br><br>";
echo "<form name=\"theform\" method=\"get\" action=\"add_devotional.php\">";
echo "Your name (this will be used in the author field):<br><input name=\"name\" type=\"text\" value=\"$name\"><br>";
echo "Your e-mail:<br><input name=\"email\" type=\"text\" value=\"$email\"><br>";
echo "Your friend's name:<br><input name=\"sendname\" type=\"text\" value=\"$sendname\"><br>";
echo "Your friend's e-mail:<br><input name=\"sendemail\" type=\"text\" value=\"$sendemail\"><br>";
echo "Your devotional (this can be no longer than 350 words) :<br><textarea name=\"devotional\" rows=12 cols=55>$devotional</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
}
if ((!$email||!$name||!$sendname||!$sendemail)&&!(!$email&&!$subject&&!$name&&!$sendname&&!$sendemail)) {
echo "You have forgotten to fill in a detail.<br>";
echo "Please correct the error(s) and resubmit the form";
echo "<style>";
if (!$email) {
echo ".email {border-color:" . $embordercolor . ";}";
}
if (!$name) {
echo ".name {border-color:" . $embordercolor . ";}";
}
if (!$sendemail) {
echo ".sendemail {border-color:" . $embordercolor . ";}";
}
if (!$sendname) {
echo ".sendname {border-color:" . $embordercolor . ";}";
}
echo "</style>";
echo "<form name=\"theform\" method=\"get\" action=\"add_devotional.php\">";
echo "Your name (this will be used in the author field):<br><input name=\"name\" type=\"text\" value=\"$name\" class=\"name\"><br>";
echo "Your e-mail:<br><input name=\"email\" type=\"text\" value=\"$email\" class=\"email\"><br>";
echo "Your friend's name:<br><input name=\"sendname\" type=\"text\" value=\"$sendname\" class=\"sendname\"><br>";
echo "Your friend's e-mail:<br><input name=\"sendemail\" type=\"text\" value=\"$sendemail\" class=\"sendemail\"><br>";
echo "Your devotional (this can be no longer than 350 words) :<br><textarea name=\"devotional\" rows=12 cols=55 class=\"devotional\">$devotional</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
if(!$email&&!$name&&!$sendname&&!$sendemail) //How can I change the code so it won't check for $sendemail and $sendname?
{
echo "Just fill in your details and devotional and an e-mail will be sent to the right person with your proposed devotional.<BR>";
echo "<form name=\"theform\" method=\"get\" action=\"add_devotional.php\">";
echo "Your name (this will be used in the author field):</b><br><input name=\"name\" type=\"text\" value=\"$name\"><br>";
echo "Your e-mail:</b><br><input name=\"email\" type=\"text\" value=\"$email\"><br>";
echo "Your friend's name:</b><br><input name=\"sendname\" type=\"text\" value=\"$sendname\"><br>";
echo "Your friend's e-mail:</b><br><input name=\"sendemail\" type=\"text\" value=\"$sendemail\"><br>";
echo "Your devotional (this can be no longer than 350 words) :</b><br><textarea name=\"devotional\" rows=12 cols=55>$devotional</textarea>";
echo "<br><input type=\"submit\" value=\"Send\" class=\"submit\"></form>";
}
?>
</body>
</html>
I don't want it to be sent to a database. I want to be able to look at it first. That way no one can add stuff to the database that I, or more inportantly my youth pastor don't want. You see I don't know much php and I just want to change what I have into something that can:
- Allow user to Input his/her:
A.name
B.email
C.Devotional/message
But no more
2.Email this data to me at me@mysite.com. In other words instead of this stuff being sent to the friend it would be sent to me. This is where I'm having problems. You see if I delete the text fields then it still checks to see if they have been filled in. I just need that fixed, that's all.
If at all possible I would prefer that as much as possible in the code be left untouched. I just need to make it so that it doesn't have those fields and doesn't check for them. I've tried many things to get it to stop checking for those fields but some how it still does or throws an error. If you could go into more detail about how to check for having 350 words that would be much appreciated too.
Thanks for your interest in helping a newbie out