I'm new to PHP, so I've been going through tutorials, FAQs, and trying to find what I need in the manual. The following script, though it looks pretty good to me, has some sort of bug because when I run it, the only output I get is: \n"; } ?> That's it. Just \n"; } ?> (7 characters (not counting spaces)) sitting in the middle of the page. I don't know just how "nit-picky" PHP is about syntax.
I'm sure I could learn a great deal if someone would be kind enough to take a look at this script and point out my (probably many) mistakes.
<HTML>
<HEAD>
<TITLE></TITLE>
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<center>
<br><br><br>
<?php
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header ("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header ("Pragma: no-cache"); // HTTP/1.0
// email message header
$message = "Thank you for using our on-line form.\n";
$message .= "Your entries were as follows -\n";
if ($ccomp) // User Input Company name
{
$client = "Client Company - $ccomp"; // Create a line for the email message
$message .= "$client\n"; // Add it to the message
}
else
{
$error = "You did not enter your Company's Name.<br>\n" ; // Error if no Company input
}
if ($ccont) // Check first Client Contact
{
$contact = "Client Contact - $ccont"; // Create a line for the email message
$message .= "$contact\n"; // Add it to the message
}
else
{
$error .= "You didn't enter Your Name.<br>\n" ; // Error if no Contact input
}
if ($ctel) // Check second line of address
{
$telephone = "Client Phone - $ctel"; // Create a line for the email message
$message .= "$telephone\n"; // Add it to the message
}
else
{
$error .= "Please include your phone number.<br>\n" ; // Error if no Phone input
}
////////// more inputs, not shown - to keep this brief /////////
// Email a copy of the message to person completing the form
if ($error == "") // Error contains nothing, send mail
{
echo "Thank you for using our on-line form.
<br><br>A copy of your details will be emailed to you almost immediately.<br><br>
<br>Please check the email and inform us of any errors as soon as possible.
<br><br>Thank you.";
// Info so sender has record of what was sent and that email is from me
mail("$cemail", "RJS Placement Form", $message, "From: Dave Marshall <dave@rjscollects.com>");
// This sends the filled out PL to me
mail("dave@rjscollects.com", "Placement", $message, "From: $cemail");
}
else // If Errors exist print message
{
print "Sorry, but the fields marked with a red cross must be completed - <br>\n";
print "$error<br>\n";
print "<br>\n";
print "<br>\n";
print "Please use your \"Back\" button to return to the form. Thank you.<br>\n";
}
?>
</center>
</BODY>
</HTML>
Thanks in advance, dave 'neobyte'
😕