lampie1978
Jun 8th 2007, 5:09 am
Hi all,
I am stuck on this stupid problem and i don't know how to solve the problem :confused:
What did I create:
I created a form that posts several variables, each variable that the form posts needs to be checked to protect the DB. After the check turns out ok then the DB is updated with the value of the variable.
The problem is that the variables that are optional and have no data are returned false and thus i cann't update the DB. I tried to skip the check when the variable is empty, but that doesn't work correctly.
Who can help, since the form has many optional variables I'll just post one.
Before i start the form:
if ($_POST[voorvoegsel] == '') { $voorvoegsel = ' '; } else { $voorvoegsel = $_POST[voorvoegsel]; }
The form:
<form name="persoonlijk" method="post" action="persoonlijk.php">
<input type="text" name="voorvoegsel" maxsize="10">
<input type='submit' name='updaten' value='Updaten'>
</form>
After the button update:
function anti_injection($voorvoegsel)
{
$verboden = array("bla", "bla");
if ($voorvoegsel != ' ')
{
if (eregi("[a-zA-Z0-9]+", $voorvoegsel)) { $voorvoegsel = trim(str_replace($verboden, '', strtolower($voorvoegsel))); } else { $voorvoegsel = HACK; echo "voorvoegsel:" .$voorvoegsel. "<br>"; }
}
$array = array('voorvoegsel'=>$voorvoegsel);
if (in_array(HACK, $array)) { die ('Sorrij uw hackpoging is mislukt.'); } else { return $array; }
}
After this the array continously returns the HACK for this variable.
Who knows what to do because i'm nearing the state of becoming crazy
Thanx
I am stuck on this stupid problem and i don't know how to solve the problem :confused:
What did I create:
I created a form that posts several variables, each variable that the form posts needs to be checked to protect the DB. After the check turns out ok then the DB is updated with the value of the variable.
The problem is that the variables that are optional and have no data are returned false and thus i cann't update the DB. I tried to skip the check when the variable is empty, but that doesn't work correctly.
Who can help, since the form has many optional variables I'll just post one.
Before i start the form:
if ($_POST[voorvoegsel] == '') { $voorvoegsel = ' '; } else { $voorvoegsel = $_POST[voorvoegsel]; }
The form:
<form name="persoonlijk" method="post" action="persoonlijk.php">
<input type="text" name="voorvoegsel" maxsize="10">
<input type='submit' name='updaten' value='Updaten'>
</form>
After the button update:
function anti_injection($voorvoegsel)
{
$verboden = array("bla", "bla");
if ($voorvoegsel != ' ')
{
if (eregi("[a-zA-Z0-9]+", $voorvoegsel)) { $voorvoegsel = trim(str_replace($verboden, '', strtolower($voorvoegsel))); } else { $voorvoegsel = HACK; echo "voorvoegsel:" .$voorvoegsel. "<br>"; }
}
$array = array('voorvoegsel'=>$voorvoegsel);
if (in_array(HACK, $array)) { die ('Sorrij uw hackpoging is mislukt.'); } else { return $array; }
}
After this the array continously returns the HACK for this variable.
Who knows what to do because i'm nearing the state of becoming crazy
Thanx