Originally posted by: jjones
Why not just use a prepared statement or the escape_string function?
I think he must be using a regex and that's probably safe enough, but call me paranoid, I just don't like unknown input going into my db without using a prepared statement or the escape_string function. Besides, if in the future he decides to allow quotes to be included in the jokes, he doesn't have to worry about remembering to fix his input sanitation.Originally posted by: binister
Originally posted by: jjones
Why not just use a prepared statement or the escape_string function?
What he said... or you could clean the data with a regexp first.
It is good that you are thinking ahead. Most people don't consider the consequences of using tainted user data.
Originally posted by: Don Rodriguez
I have a site where a user can input their favorite jokes. The characters inserted should only be A-Za-z1-9 period comma colon semi colon and the space... can I restrict all input to those characters and not have to worry about sql injection?
Originally posted by: KB
Originally posted by: Don Rodriguez
I have a site where a user can input their favorite jokes. The characters inserted should only be A-Za-z1-9 period comma colon semi colon and the space... can I restrict all input to those characters and not have to worry about sql injection?
Yep Stored Procedures FTW!
In your scenario nothing stops the user from saving the HTML source of your page, editing the source to remove your input validation, then submitting anything they want.
Originally posted by: tfinch2
Originally posted by: KB
Originally posted by: Don Rodriguez
I have a site where a user can input their favorite jokes. The characters inserted should only be A-Za-z1-9 period comma colon semi colon and the space... can I restrict all input to those characters and not have to worry about sql injection?
Yep Stored Procedures FTW!
In your scenario nothing stops the user from saving the HTML source of your page, editing the source to remove your input validation, then submitting anything they want.
😕
Hopefully, that javascript is just an aid to be sure the average user is putting in the correct info and real validation goes on server side. I mean you're doing the same thing using just combo boxes and restricting input to selectable options, but that doesn't mean it's worth a damn for validation. I would hope the javascript is being used for the same sort of purpose.Originally posted by: LoKe
Originally posted by: tfinch2
Originally posted by: KB
Originally posted by: Don Rodriguez
I have a site where a user can input their favorite jokes. The characters inserted should only be A-Za-z1-9 period comma colon semi colon and the space... can I restrict all input to those characters and not have to worry about sql injection?
Yep Stored Procedures FTW!
In your scenario nothing stops the user from saving the HTML source of your page, editing the source to remove your input validation, then submitting anything they want.
😕
He's kinda right. I've seen a few websites use Javascript on the form itself to allow only certain characters. All you'd have to do is make your own and do http://site.com/target.php and input your values that way.
Originally posted by: LoKe
Originally posted by: tfinch2
Originally posted by: KB
Originally posted by: Don Rodriguez
I have a site where a user can input their favorite jokes. The characters inserted should only be A-Za-z1-9 period comma colon semi colon and the space... can I restrict all input to those characters and not have to worry about sql injection?
Yep Stored Procedures FTW!
In your scenario nothing stops the user from saving the HTML source of your page, editing the source to remove your input validation, then submitting anything they want.
😕
He's kinda right. I've seen a few websites use Javascript on the form itself to allow only certain characters. All you'd have to do is make your own and do http://site.com/target.php and input your values that way.
Originally posted by: tfinch2
I understand that. But anyone using only client-side validation is asking for what's coming to them.
Originally posted by: LoKe
Originally posted by: tfinch2
I understand that. But anyone using only client-side validation is asking for what's coming to them.
You'd be surprised how common it is.