I'm attempting (as a novice) to build a page to process comments. The form
displays the first time, but the error checking seems to be getting into the
way of it working. It is located on a unix server at
www.mokenamartialarts.com/mytest.php. Here is the code:
AITTC Tae Kwon Contact
// mytest.php
// testing a comment page that emails it
$form_block = "
";
//testing at line 44-5
echo "*proc_check is *$_POST[proc_check]*";
if ($_POST[proc_check] != "sent")
{
echo "$form_block"; }
else if ($_POST[proc_check] == "sent")
{
$send = "yes";
$name_err = "";
$email_err = "";
$comment_err = "";
$to = "affordable_turnkey_solutions@comcast.net";
$subject = "TDK Comment";
$mailheader = "From: AITTC web site <> ";
$mailheader .= "Reply-To: $_POST[sender_email]\n\n";
$msg = "email sent from www.mokenamartialarts.com\n";
if ($_POST[sender_name] == "")
{ $name_err = "Enter your name please.";
$send = "no" };
if ($_POST[sender_email] == "")
{ $email_err = "Enter your email please.";
$send = "no" };
if ($_POST[sender_comment] == "")
{ $comment_err = "Enter your comment
please.";
$send = "no" };
Lee David wrote:
> I'm attempting (as a novice) to build a page to process comments. The form
> displays the first time, but the error checking seems to be getting into the
> way of it working. It is located on a unix server at
> www.mokenamartialarts.com/mytest.php. Here is the code:
Your if-statements are wrong, you can't write
if(true) { echo "hello" };
The ';' is on the wrong side of '}'.
You had some $POST, which should be $_POST.
IMHO you are making a bad thing of making your form_block variable, there is
no need of letting php work extra, as you can output the whole thing as normal
HTML instead.
example that seems to spam you:
AITTC Tae Kwon Contact
echo "*proc_check is *$_POST[proc_check]*";
if ($_POST[proc_check] != "sent") {
?>
} else if ($_POST[proc_check] == "sent") {
$send = "yes";
$name_err = "";
$email_err = "";
$comment_err = "";
$to = "affordable_turnkey_solutions@comcast.net";
$subject = "TDK Comment";
$mailheader = "From: AITTC web site <> ";
$mailheader .= "Reply-To: $_POST[sender_email]\n\n";
$msg = "email sent from www.mokenamartialarts.com\n";
if ($_POST[sender_name] == "") {
$name_err = "Enter your name please.";
$send = "no";
}
if ($_POST[sender_email] == "") {
$email_err = "Enter your email please.";
$send = "no";
}
if ($_POST[sender_comment] == "") {
$comment_err = "Enter your comment please.";
$send = "no";
}
if ($send == "yes") {
$msg .= "Sender name = $_POST[sender_name]\n\n";
$msg .= "Sender email = $_POST[sender_email]\n\n";
$msg .= "Sender comment = $_POST[sender_comment]\n\n";
mail($to, $subject, $msg, $mailheader);
echo "
Thank you for looking at it. I was copying an example out of a book. They
said they were using the variable for the form so it could be redisplayed.
When I try to redisplay the page to keep working on it, I only get the
"sent" message. I have to go to a different page and come back to see the
form again. Is there a different way to do that?
Are the "$_POST" variables case sensitive?
Thanks, I'm going to check out your modification.
Jerry
"J.O. Aho" wrote in message
news:3abesbF6b8ln2U1@individual.net...
> Lee David wrote:
>> I'm attempting (as a novice) to build a page to process comments. The
>> form displays the first time, but the error checking seems to be getting
>> into the way of it working. It is located on a unix server at
>> www.mokenamartialarts.com/mytest.php. Here is the code:
>
> Your if-statements are wrong, you can't write
> if(true) { echo "hello" };
> The ';' is on the wrong side of '}'.
>
> You had some $POST, which should be $_POST.
>
> IMHO you are making a bad thing of making your form_block variable, there
> is no need of letting php work extra, as you can output the whole thing as
> normal HTML instead.
>
> example that seems to spam you:
>
>
>
>
> AITTC Tae Kwon Contact
>
>
>
>
>
> echo "*proc_check is *$_POST[proc_check]*";
>
> if ($_POST[proc_check] != "sent") {
> ?>
>
>
> } else if ($_POST[proc_check] == "sent") {
> $send = "yes";
> $name_err = "";
> $email_err = "";
> $comment_err = "";
> $to = "affordable_turnkey_solutions@comcast.net";
> $subject = "TDK Comment";
> $mailheader = "From: AITTC web site <> ";
> $mailheader .= "Reply-To: $_POST[sender_email]\n\n";
> $msg = "email sent from www.mokenamartialarts.com\n";
>
> if ($_POST[sender_name] == "") {
> $name_err = "Enter your name please.";
> $send = "no";
> }
> if ($_POST[sender_email] == "") {
> $email_err = "Enter your email please.";
> $send = "no";
> }
> if ($_POST[sender_comment] == "") {
> $comment_err = "Enter your comment
> please.";
> $send = "no";
> }
> if ($send == "yes") {
> $msg .= "Sender name = $_POST[sender_name]\n\n";
> $msg .= "Sender email = $_POST[sender_email]\n\n";
> $msg .= "Sender comment = $_POST[sender_comment]\n\n";
> mail($to, $subject, $msg, $mailheader);
> echo "
Lee David wrote:
> Thank you for looking at it. I was copying an example out of a book. They
> said they were using the variable for the form so it could be redisplayed.
Yes, that could be a reason, but you could make it into a function too
function showform($var="") {
if(strlen($var) {
echo $var;
}
?>
}
Then you can call the function as many times you want.
if(strlen($_POST['info'])) {
if($_POST['info']=="hello") {
showform("Hello isn't any form of usefull information \n");
} else {
echo "Thanks for the information \n";
}
} else {
showform();
}
And in this example the function can do more than the variable, it can handle
input and modify the output too. If you work on it a bit, you could get the
form what information was missing when first tried to submit it.
> When I try to redisplay the page to keep working on it, I only get the
> "sent" message. I have to go to a different page and come back to see the
> form again. Is there a different way to do that?
You most likely resend the data too, you could just put a simple link to
itself on the page, so you clear out the data and so way see the page again.
Another option could be to use a Gecko based browser, see at mozilla.org
> Are the "$_POST" variables case sensitive?
Yes, it's case sensitive.
//Aho
Re: Comment form failure
am 25.03.2005 18:24:05 von Lee David
I posted this in the "altcomp.lang.php" newsgroup so I hope you don't mind
me putting it here as well.
How do I search a newsgroup to find answers to things? The "Find" function
in OE didn't do the job afaik.
How do I force the form's email address into the "From" of the mail()
function? I thought the header variable would do that, but it doesn't seem
to have.
TIA,
Jer
"J.O. Aho" wrote in message
news:3abkjaF64bmm8U1@individual.net...
> Lee David wrote:
>> Thank you for looking at it. I was copying an example out of a book.
>> They said they were using the variable for the form so it could be
>> redisplayed.
>
> Yes, that could be a reason, but you could make it into a function too
>
> function showform($var="") {
> if(strlen($var) {
> echo $var;
> }
> ?>
>
>
> }
>
> Then you can call the function as many times you want.
>
> if(strlen($_POST['info'])) {
> if($_POST['info']=="hello") {
> showform("Hello isn't any form of usefull information \n");
> } else {
> echo "Thanks for the information \n";
> }
> } else {
> showform();
> }
>
> And in this example the function can do more than the variable, it can
> handle input and modify the output too. If you work on it a bit, you could
> get the form what information was missing when first tried to submit it.
>
>
>> When I try to redisplay the page to keep working on it, I only get the
>> "sent" message. I have to go to a different page and come back to see
>> the form again. Is there a different way to do that?
>
> You most likely resend the data too, you could just put a simple link to
> itself on the page, so you clear out the data and so way see the page
> again.
> Another option could be to use a Gecko based browser, see at mozilla.org
>
>> Are the "$_POST" variables case sensitive?
>
> Yes, it's case sensitive.
>
>
>
> //Aho