So I am having a really hard time with PHP >:(
I am taking a web design program and I am in my first semester of PHP, and I am learning that it’s not like CSS or HTML, where you can kind of cut and paste from the text book and then massage it into doing what you want it to
I am having a lot of frustration with it :’(
Here is my code for the form:
[i]
Simple Feedback FormYour name:
Your email address:
Subject:
Message:
and here is the php:
[php]
[i]<?
if (($_POST[sender_name] == “”) ||
($_POST[sender_email] == “”) ||
($_POST[subject] == “”) ||
($_POST[message] == “”)) {
header(“Location: simple_form.html”);
exit;
}
$msg = “Email sent from www site\n”;
$msg .= “Sender’s name: \t$_POST[sender_name]\n”;
$msg .= “Sender’s email: \t$_POST[email]\n”;
$msg .= “Message: \t$_POST[message]\n”;
$to = “[email protected]”;
$subject = “\t$_POST[subject]\n”;
$mailheaders = “From: My website [email protected]\n”;
$mailheaders .= “Reply-To: $_POST[sender_email]\n”;
mail($to, $subject, $msg, $mailheaders);
if ($_POST[op] != “ds”) {
echo “$form_block”;
}
else if ($_POST[op] == “ds”) {
$_POST[sender_name]:
if ($_POST[sender_name] == “”) {
$name_err = “Please enter your name!
”;
$send = “no”;
$_POST[sender_email]:
if ($_POST[sender_email] == “”) {
$email_err = “Please enter your e-mail
address!
”;
$send = “no”;
}
$_POST[subject]:
if ($_POST[subject] == “”) {
$subject_err = “Please enter a message!
”;
$send = “no”;
}
$_POST[message]:
if ($_POST[message] == “”) {
$message_err = “Please enter a message!
”;
$send = “no”;
}
if ($send != “no”) {
$msg = “Email sent from www site\n”;
$msg .= “Sender’s name: \t$_POST[sender_name]\n”;
$msg .= “Sender’s email: \t$_POST[email]\n”;
$msg .= “Message: \t$_POST[message]\n”;
$to = “[email protected]”;
$subject = “\t$_POST[subject]\n”;
$mailheaders = “From: My website [email protected]\n”;
$mailheaders .= “Reply-To: $_POST[sender_email]\n”;
mail($to, $subject, $msg, $mailheaders);
echo “
Your email has been sent.
”;else if ($send == “no”) {
echo “$name_err”;
echo “$email_err”;
echo “$subject_err”;
echo “$message_err”;
}
}
?>
The following email has been sent:
Your name:
<? echo "$_POST[sender_name]"; ?>
Your email address:
<? echo "$_POST[sender_email]"; ?>
Your subject:
<? echo "$_POST[subject]"; ?>
Message:
<? echo "$_POST[message]"; ?>
If there is an error in the above information, please feel free to resend your email with a correction notice in the subject line (so I know which email to respond to)
</body [/i] [/php]This is the error that I am getting:
Parse error: syntax error, unexpected T_IF in C:\xampp\htdocs\sbarager\send_simp
I just know that I am not going to learn very much about PHP by the end of the semester. Could somebody please tell me what I have done wrong in my code, and can you also recommend a good book/site on PHP that I can use to teach myself how to code properly with PHP?
Also, here is the book that’s been assigned:
Any comments would be greatly appreciated