Forum Moderators: coopster
like this:
[success/error message here, but hidden until there's a reason to display something]
- name box
- input box
- comment box
- submit button
here is a snippet of what i currently have. what this portion does, if there's an error.. the user is redirected to a white page and in the upper left-hand corner they are told "error! bla bla..." or "success!"
---
if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
{
echo "That is not a valid email address."
."try again.";
exit;
}
mail($toemail, $subject, $body, $headers);
echo "Thanks!";
---end of form---
<body>
<?
if (!ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email))
{
echo "That is not a valid email address."
."try again.";
} elseif (ereg("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$", $email)) {
Thank you.
};
?>
<form....>
- name box - value='<? echo $name;?>'
- input box
- comment box
- submit button
</form>
</body>
the web form will always be at the bottom. You can also add values for the input so on email error the name and comment can be automatically filled in. But you should also check if the email was sent or not.
Hope this helps.
Regards,
Vevs
<?phpif (isset($_POST['submit']))
{
$name = trim($_POST['name']);
$email = trim($_POST['email']);
$subject = trim($_POST['subject']);
$comments = trim($_POST['comments']);$errors = false;
if ($name=='' ¦¦ $email=='' ¦¦ $subject=='' ¦¦ $comments=='')
{
$errors = true;
}}
?>
<html>
<head><title></title>
</head><body>
<?php
if (isset($_POST['submit']) && $errors)
{
echo "Please complete all fields!";
}
if (isset($_POST['submit']) &&!$errors)
{
echo "Thank you! Message Sent!";
}
?>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>">
Name: <input type="text" name="name"><br>
E-Mail: <input type="text" name="email"><br>
Subject :<input type="text" name="subject"><br>
Comments: <textarea name="comments" rows="5" cols="20"></textarea>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Thats just cheap and nasty, but hopefully you get the idea. I haven`t tested it, but should give you some starters. Note that if you copy and paste, re-type the pipes.
dc