|
Posted by Kimmo Laine on 06/03/05 18:35
"Chris B" <zen19389@zen.co.uk> kirjoitti
viestissδ:42a060fc$0$23699$db0fefd9@news.zen.co.uk...
>I am trying to create a "foolproof" login.
>
> Basically people can type their name in with no password or registration,
> this is done on trust and so that the site can keep track of them.
> All the scripts to hold this in place work perfectly however I'm
> struggling with the handling of an input with one or more text.
>
>
> The sql type of username is varchar(64) so what I'm trying to work out is
> how to say "if there is one or more space in the input, use their ip",
> which I have already worked out and is stored in $ip
>
> I've tried
> if ($username == " ") $username = "Mr or Miss ".$ip;
>
> But submitting my name as a space, or even as doesn't trigger that
> line and the site knows me as " " (without quotes)
>
> How come the above line doesn't work, and as a bonus question, how can I
> make it check if there is more than one space (if some cunning git puts 30
> of them for example) and still trigger the above or a similar line?
run the input through trim* and see if there are any valid characters left,
meaning the string still has a non-zero length.
for example
if(strlen($username = trim($username)))<1)
$username = "Mr or Miss ".$ip;
That way if luser inputs spaces, tabs, whatever that is concidered
"whitespace", trim will remove them and what's left is then checked. That
way " John Doe " turns into "John Doe" and " " turn into "",
which has length less than 1 and thus becomes "Mr or Miss 127.0.0.1".
*) trim -- Strip whitespace from the beginning and end of a string
--
"I am pro death penalty. That way people learn
their lesson for the next time." -- Britney Spears
eternal.erectionN0@5P4Mgmail.com
Navigation:
[Reply to this message]
|