in reply to Re: User Existance?
in thread User Existance?

why am i getting an error when trying to run this?
if getpwnam($username) { $message = $message.'<p>The Chosen Username Already Exists.</p>'; $found_err = 1; }
Also, if i run mad-hatters code and change the username to root, it does not display that the username is in use!

Replies are listed 'Best First'.
Re: Re: Re: User Existance?
by isotope (Deacon) on May 17, 2003 at 23:08 UTC
    What's the error? As for not complaining about root, perldoc -f getpwnam mentions that the return value is the uid corresponding to the name, or undef if the username does not exist. Root is uid 0, so you really need to check the definedness of the return value:
    if(defined(getpwnam($username))) ...
    Post the error message and we'll figure it out.

    --isotope
      I forgot about that little caveat. Thanks for pointing it out. As for the error, it is most likely the lack of parentheses around the conditional for the if statement, as I said before.