It does and it
doesnt. You
have simply
left out a
parameter of
the function.
This funtion
requires 3
parameters:
str_replace(
-search- ,
-replace- ,
-subject-);
-search- = What
you are looking
for (to
replace). In
this case, you
forgot the
$junk array.
You are looking
to replace
invalid
characters.
-replace- =
what you want
to replace the
-search- with.
In your case,
if it found an
invalid
character, you
want it to
remove it, or
''.
-subject- =
Variable name
to which the
function
applies. In
your case,
$_POST['userna
me'].
In the
register.php
script, we take
the length of
the username
the visitor has
selected. Then,
we strip out
any unwanted
characters (via
the
str_replace();
function). Then
check if the
lengths are
different. If
they are, then
the function
found an
invalid
character, so
at that point
we would error
out and tell
them to remove
invalid
characters. If
not, it is safe
to proceed
through the
rest of the
script.
Hope that helps
|