Hi
I would like to be able to add a comments box to a simple form please, but I am stuck on how to do it. I can add other input type=text boxes, but not the text area boxes. Any suggestions would be appreciated.
Thanks,
Phil
<?php # Script 3.15 - register.php
if (isset($_POST['submit'])) { // Handle the form.
$message = NULL; // Create an empty new variable.
// Check for a name.
if (strlen($_POST['name']) > 0) {
$name = TRUE;
} else {
$name = FALSE;
$message .= '<p>You forgot to enter your name!</p>';
}
// Check for an email address.
if (strlen($_POST['email']) > 0) {
$email = TRUE;
} else {
$email = FALSE;
$message .= '<p>You forgot to enter your email address!</p>';
}
// Check for a username.
if (strlen($_POST['username']) > 0) {
$username = TRUE;
} else {
$username = FALSE;
$message .= '<p>You forgot to enter your user name!</p>';
}
// Check for a username.
if (strlen($_POST['telephone']) > 0) {
$telephone = TRUE;
} else {
$telephone = FALSE;
$message .= '<p>You forgot to enter your telephone number!</p>';
}
if ($name && $email && telephone ) { // If everything's okay.
// Register the user.
// Send an email.
$to = $_POST['email'];
$message = "Thank you for your enquiry! Here is a copy of what you have submitted, we will contact you shortly.\n\nPlease do not reply to this email.\n\nYour name is '{$_POST['name']}'\n\nYour email is '{$_POST['email']}'\n\nYour telephone number is'{$_POST['telephone']}'\n\nSincerely,\nPH Cleaning Ltd";
$subject = 'Your Enquiry'; // Create an empty new variable.
$headers .= 'From: enquiries@mysite.com' . "\r\n";
$headers .= 'Bcc: forms@mysite.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
header ('Location: thank_you.php');
exit();
} else {
$message .= '<p>Please try again.</p>';
}
}
// Print the error message if there is one.
if (isset($message)) {
echo '<font color="red">', $message, '</font>';
}
?>
Here is the form code also
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<fieldset><legend>Request a call back</legend>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="left"><b>Name:</b> </td>
<td align="left"><input type="text" name="name" size="20" maxlength="40" value="<?php if (isset($_POST['name'])) echo $_POST['name']; ?>" /></td>
</tr>
<tr>
<td align="left"><b>Email Address:</b> </td>
<td align="left"><input type="text" name="email" size="40" maxlength="60" value="<?php if (isset($_POST['email'])) echo $_POST['email']; ?>" /></td>
</tr>
<tr>
<td align="left"><b>Telephone:</b> </td>
<td align="left"><input type="text" name="telephone" size="20" maxlength="40" value="<?php if (isset($_POST['telephone'])) echo $_POST['telephone']; ?>" /></td>
</tr>
<tr>
<td valign="top"> </td>
<td align="left"><input type="submit" name="submit" value="Submit" /></td>
</tr>
<tr>
<td colspan="2"><p>
</p>
<p> </p></td>
</tr>
</table>
</fieldset> </form>