Actually I tried a variation of what you gave me before and it didnt work. I
couldnt get yours to validate thanks. heres what I used
<?php
if (getenv("REQUEST_METHOD") == "POST")
{
if (
eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $Email)
&& eregi("^[a-z0-9]$", $FirstName)
&& eregi("^[a-z0-9]$", $LastName)
)
{
echo "thanks";
}
else
{
echo "error!";
}
}
?>
This is directly after the form using the registered vars $Email,
$FirstName, $LastName. So I dunno whats wrong..
> From: "W.D." <[EMAIL PROTECTED]>
>
> > I dont know how to do this, but Ive tried several things with no
success.
> I
> > need to validate several form fields and here is the script I'm working
> > with...
> >
> > <?php if($HTTP_SERVER_VARS["REQUEST_METHOD"] == "POST")
> > {
> > (eregi("^[a-z0-9\._-]+@+[a-z0-9\._-]+\.+[a-z]{2,3}$", $Email))?
> > header("Location: http://www.site.com/thanks.php"):
> > header("Location: http://www.site.com/error.php");
> > }
> > ;?>
> >
> > I need to check at least two more fields, possibly 3 but I keep getting
> > errors when trying to loop through a bunch of if statements. The above
> works
> > fine but I need to check eregi() against more strings from fields which
> then
> > redirects as shown above. Anyone?
> >
>
>
> <?php
> if (getenv("REQUEST_METHOD") == "POST")
> {
> if (
> eregi("pattern1", $field1)
> && eregi("pattern2", $field2)
> && eregi("pattern3", $field3)
> )
> {
> echo "thanks";
> }
> else
> {
> echo "error!";
> }
> }
> ?>
>
>
> Or if you want better error reporting:
>
>
> <?php
> if (getenv("REQUEST_METHOD") == "POST")
> {
> $errors = array();
>
> if (!eregi("pattern1", $field1))
> {
> $errors[] = "field1 is not right";
> }
> if (!eregi("pattern2", $field2))
> {
> $errors[] = "field2 is not right";
> }
> if (!eregi("pattern3", $field3))
> {
> $errors[] = "field3 is not right";
> }
>
> if (count($errors) > 0)
> {
> echo "Sorry, " . count($errors) . " errors occurred, please
try
> again.\n<ul>";
> foreach ($errors as $err)
> {
> echo "<li>$err\n";
> }
> echo "</ul>";
> }
> }
> ?>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]