Hi there, I hope I’ve used the tags right on the site to display this. I’m trying to create an email form, but my error page isn’t working. Hope someone can help, thanks
[php]<?php
// Information to be modified
if (isset($_POST[“recipient”])) {
$rec = $_POST[“recipient”];
}
if ($rec == “Jim”) {
$your_email="[email protected]";
}
elseif ($rec == “Angie”) {
$your_email="[email protected]";
}
else {
$your_email="[email protected]";
}
$subject = “Message from WEBSITE”; // subject of the email that is sent
$thanks_page = “thankyou.html”; // path to the thank you page following successful form submission
//
if (isset($_POST[“submit”])) {
$nam = $_POST[“name”];
$ema = trim($_POST[“email”]);
$com = $_POST[“comments”];
$loadtime = $_POST[“loadtime”];
if (get_magic_quotes_gpc()) {
$nam = stripslashes($nam);
$ema = stripslashes($ema);
$com = stripslashes($com);
}
$error_msg=array();
if (empty($nam) || !preg_match("/^[\s.’-\pL]{1,60}$/u", $nam)) {
$error_msg[] = “The name field must contain only letters, spaces and basic punctuation (. - ')”;
}
if (empty($ema) || !filter_var($ema, FILTER_VALIDATE_EMAIL)) {
$error_msg[] = “Your email must have a valid format, such as [email protected]”;
}
$limit = 1000;
if (empty($com) || !preg_match("/^[0-9/-\s’()!?.,:;\pL]+$/u", $com) || (strlen($com) > $limit)) {
$error_msg[] = “The Comments field must contain only letters, digits, spaces and basic punctuation ( ’ - , . : ; / and parentheses), and has a limit of 1000 characters”;
}
$totaltime = time() - $loadtime;
if($totaltime < 7) {
echo(“Please fill in the form before submitting!”);
exit;
}
// Assuming there’s an error, refresh the page with error list and repeat the form
if ($error_msg) {
echo ’
<div class="content">
<h1>Oh dear!</h1>
<p>Unfortunately, your message could not be sent. The form as you filled it out is displayed below. Make sure each field completed, and please also address any issues listed below:</p>
<ul class="err">';
foreach ($error_msg as $err) {
echo ‘
}
echo ’
Name
<input name=“name” type=“text” size=“40” maxlength=“60” id=“name” value="’; if (isset($_POST[“name”])) {echo $nam;}; echo ‘">
Email Address
<input name=“email” type=“email” size=“40” maxlength=“60” id=“email” value="’; if (isset($_POST[“email”])) {echo $ema;}; echo '">
Comments
'; if (isset($_POST[“comments”])) {echo $com;}; echo ’
$email_body =
"Name of sender: $nam\n\n" .
"Email of sender: $ema\n\n" .
"COMMENTS:\n\n" .
"$com" ;
// Assuming there’s no error, send the email and redirect to Thank You page
if (!$error_msg) {
mail ($your_email, $subject, $email_body, “From: JAF-Waste noreply@WEBSITE\r\n”. “Reply-To: $nam <$ema>” . “Content-Type: text/plain; charset=utf-8”);
header (“Location: $thanks_page”);
exit();
}
}
?>
Contact details |
|
JIM | ANGIE |
PHONE NUMBER |
PHONE NUMBER |
Alternatively you can use the form below
<div>
<label for="name">Name</label>
<input name="name" type="text" id="name" placeholder="your name" value="<?php if (isset($_POST["name"])) {echo $nam;} ?>">
</div>
<div>
<label for="email">Email Address</label>
<input name="email" type="email" id="email" placeholder="your email address" value="<?php if (isset($_POST["email"])) {echo $ema;} ?>">
</div>
<div>
<label for="comm">Comments</label>
<textarea name="comments" rows="5" id="comm"><?php if (isset($_POST["comments"])) {echo $com;} ?></textarea>
</div>
<input type="hidden" name="loadtime" value="<?php echo time(); ?>">
<div>
<input type="submit" name="submit" value="Send">
</div>
</form>
input[type=“text”], input[type=“email”], textarea {
font-size: 0.75em; width: 98%; font-family: arial; border: 1px solid #ebebeb; padding: 4px; display: block;
}
input[type=“radio”] {
margin: 0 5px 0 0;
}
textarea {
overflow: auto;
}
#contact{
margin: 0 0 10px 0; ;
}
#banner {
position:absolute;
left: 0px;
top: 0px;
background-color: #d6d6d6;
border-bottom: 2px solid #434A57;
height: 110px;
width: 100%;
z-index: 1;
}
#holder {
top: 111px;
left: 0px;
width: 100%;
height:22px;
position: absolute;
border-bottom: 2px solid #434A57;
z-index: 2;
}
#links {
top: 0px;
left: 10px;
position: absolute;
z-index: 1;
}
a {
font-family:“Lucida Sans Unicode”, “Lucida Grande”, sans-serif;
font-size:medium;
width: 500px;
height: 22px;
color: #434A57;
}
#contactus {
top: 120px;
left: 100px;
position: absolute;
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size:medium;
width: 500px;
height: 500px;
z-index: 1;
color: #434A57;
}
@media (max-width: 1000px) {
.van {
display: none; }
}
#van {
position: absolute;
right:0px;
bottom: 0px;
}
[/code]