I have file which I use for validating which includes the following
function:

function invalidchar($strvalue)
{
        if(!ereg("^[[:alpha:][:space:]\'-.]*$", $strvalue)) {
                         return "*";
        }
}

Here is the problem. If I don't use the function, like below, there is no
problem.

        if (empty($person)) { $formerror['person'] = "*"; }
        elseif(!ereg("^[[:alpha:][:space:]\'-.]*$", $person)) {
                         $formerror['person'] = "*";
        }

If I use the one below it says $formerror['person'] is set, but if I echo it
there is nothing in it. But here is the kicker, I have several other scripts
that use the same function with no problems. In fact, I have another form
which uses the code below with no problems. So I am at a loss as to what the
problem is. I have deleted all other validating except for the one below to
try and narrow this down, but still at a loss. One last thing, if I unset
$formerror['person'] at the end of the code below, it works. So obviously it
has a value - but what is it and how is it getting it?????? Am I just losing
it????

        if (empty($person)) { $formerror['person'] = "*"; }
        else { 
                $formerror['person'] = invalidchar($person); 
        }

Any help before I go insane.

This is the entire code:::

<? 
session_start(); 

if(isset($_SESSION['nodatabase'])) { unset($_SESSION['nodatabase']); }
$databasename = "database";
include_once("constants.php");  // This has the functions in it

if($mysubmit && !$_SESSION['added']) {

        $name = slashstrip( $_POST['person'] );
        $place = slashstrip( $_POST['place'] );
        $comment = slashstrip( $_POST['comment'] );

        if (empty($person)) { $formerror['person'] = "*"; }
        else { 
                $formerror['person'] = invalidchar($name); 
                if($formerror['person']) { $formerror['person'] = "*"; }
        }


        if (!$formerror) {
                
                // Calls function to write entries to database - which works
if I could get here
                
                $inserterror = writerecord($today, $_SESSION['cfname'],
$person, $place, $comment, $ipaddrs);
                if($inserterror) { 
                        $headerror = $inserterror;  
                }
                else { $_SESSION['added'] = True; }
        }
        else { $headerror = formerrors; }
}

?>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to