Forum Moderators: coopster

Message Too Old, No Replies

getting toes wet and drowning

         

Kysmiley

4:16 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



Well after many months of reading and re-reading books tutorials and posts I have decided to get my toes wet with PHP.
I have a problem Im hoping somone can help me with. I have created a feedback form and used snippets of codes from this forum with alterations added to make it fit my needs. My problem is that when I hit the submit button on the form it takes me to a page showing me all kinds of coding.
EG:
Please go back and fill out any missing fields"; exit; } //opening and sending feedback email else {$toaddress = 'pat@mysite.com'; $subject = 'subject'; $mailcontent = 'Customer name: '.$name."\n" .'Customer email: '.$email."\n" .'Customer Telephone number: '.$telephone."\n" ."Customer comments: \n".$suggestion."\n"; $fromaddress = 'From: feedback@mysite.com'; mail($toaddress, $subject, $mailcontent, $fromaddress) } if (mail($toaddress, $subject, $mailcontent, $fromaddress)) else { echo "

Success: all fields were filled out correctly and has been sent to the appropriate department"; } else { echo "

email could not be sent"; }?>

here is my script Please point me in the right direction to fix this or if im missing " or ' let me know. I dont get any error messages.
Pat

</php

// creating an error messages
$errmsg = "";
if (!isset($_POST['name']) ¦¦ empty($_POST['name'])) $errmsg .= "<p>I'm sorry it seems like you have forgotten to include your name in the form";
if (!isset($_POST['email']) ¦¦ empty($_POST['email'])) $errmsg .= "<p>I'm sorry it seems like you have forgotten to include your E-mail address in the form this may be helpful if you would like us to contact you";
if (!isset($_POST['name']) ¦¦ empty($_POST['name'])) $errmsg .= "<p>I'm sorry it seems like you have forgotten to include your name in the form";
if (!isset($_POST['suggestion']) ¦¦ empty($_POST['suggestion'])) $errmsg .= "<p>I'm sorry it seems like you have forgotten to include your comments in the form";
if ($_POST['subject'] == "none") $errmsg .= "<p>Please select a catagory you would like to comment on";

if ($errmsg!= "") {
echo $errmsg;
echo "<a href=\"javascript:history.back();\">Please go back and fill out any missing fields</a>";
exit;
}
//opening and sending feedback email

$toaddress = 'pat@mysite.com';
$subject = 'subject';
$mailcontent = 'Customer name: '.$name."\n"
.'Customer email: '.$email."\n"
.'Customer Telephone number: '.$telephone."\n"
."Customer comments: \n".$suggestion."\n";
$fromaddress = 'From: feedback@mysite.com';
else{
mail ($toaddress, $subject, $mailcontent, $fromaddress)

}
if (mail($toaddress, $subject, $mailcontent, $fromaddress))
echo "<p>Success: all fields were filled out correctly and has been sent to the appropriate departments";
}
else {
echo "<p>email could not be sent";
}
?>

Robber

4:47 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



Its the start of your php block that seems to be the offender:

</php

// creating an error messages
$errmsg = "";

should be:

<?php

Hope that helps.

Kysmiley

4:53 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



should have known it would be something simple.
Now tp start dealling with error messages
Parse error: parse error, unexpected T_ELSE in /home2/www/mysite/dir/suggest.php on line 25
will look more at this when I get back
Thanks again
Pat

Robber

5:17 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



Your else{ starts in the middle of nowhere, the error is telling you that you cant have an "else" that isnt attached to an "if". Only had a quick look, but maybe all this:
if ($errmsg!= "") {
echo $errmsg;
echo "<a href=\"javascript:history.back();\">Please go back and fill out any missing fields</a>";
exit;
}
//opening and sending feedback email

$toaddress = 'pat@mysite.com';
$subject = 'subject';
$mailcontent = 'Customer name: '.$name."\n"
.'Customer email: '.$email."\n"
.'Customer Telephone number: '.$telephone."\n"
."Customer comments: \n".$suggestion."\n";
$fromaddress = 'From: feedback@mysite.com';
else{
mail ($toaddress, $subject, $mailcontent, $fromaddress)

}

Should be:

if ($errmsg!= "") {
echo $errmsg;
echo "<a href=\"javascript:history.back();\">Please go back and fill out any missing fields</a>";
exit;
}else{
//opening and sending feedback email

$toaddress = 'pat@mysite.com';
$subject = 'subject';
$mailcontent = 'Customer name: '.$name."\n"
.'Customer email: '.$email."\n"
.'Customer Telephone number: '.$telephone."\n"
."Customer comments: \n".$suggestion."\n";
$fromaddress = 'From: feedback@mysite.com';

mail ($toaddress, $subject, $mailcontent, $fromaddress)

}

Robber

5:18 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



and you need a ;

mail ($toaddress, $subject, $mailcontent, $fromaddress)

mail ($toaddress, $subject, $mailcontent, $fromaddress);

Kysmiley

8:23 pm on Nov 26, 2004 (gmt 0)

10+ Year Member



Thanks Robber, that fixed a few of the problems. I still had the odd { in the wrong place or reversed. It works now though.
Now to play and modify the html output more.
It also is missing a field in the content section that I need to find out why
Pat.
Well this is the best way they say to learn is just jump in, right?