All Questions

324
votes
11answers
201591 views

Asking the user for input until they give a valid response

I am writing a program that must accept input from the user. #note: Python 2.7 users should use `raw_input`, the equivalent of 3.X's `input` age = int(input("Please enter your age: ")) if age >= 1...
929
votes
15answers
407801 views

What's the best method for sanitizing user input with PHP?

Is there a catchall function somewhere that works well for sanitizing user input for SQL injection and XSS attacks, while still allowing certain types of html tags?
175
votes
20answers
79150 views

How do you implement a good profanity filter?

Many of us need to deal with user input, search queries, and situations where the input text can potentially contain profanity or undesirable language. Oftentimes this needs to be filtered out. Where...
50
votes
9answers
34857 views

Disadvantages of scanf

I want to know the disadvantages of scanf(). In many sites, I have read that using scanf might cause buffer overflows. What is the reason for this? Are there any other drawbacks with scanf?
35
votes
1answers
2252 views

How can I add user-supplied input to an SQL statement?

I am trying to create an SQL statement using user-supplied data. I use code similar to this: var sql = "INSERT INTO myTable (myField1, myField2) " + "VALUES ('" + someVariable + "', '" + so...
40
votes
4answers
31643 views

How do I read multiple lines of raw input in Python?

I want to create a Python program which takes in multiple lines of user input. For example: This is a multilined input. It has multiple sentences. Each sentence is on a newline. How can I take in m...
126
votes
5answers
155332 views

Spring MVC: How to perform validation?

I would like to know what is the cleanest and best way to perform form validation of user inputs. I have seen some developers implement org.springframework.validation.Validator. A question about that:...
204
votes
21answers
119046 views

How to show "Done" button on iPhone number pad

There is no "Done" button on the number pad. When a user finishes entering numeric information in a text field, how can I make the number pad disappear? I could get a "Done" button by using the defau...
50
votes
7answers
51479 views

JUnit testing with simulated user input

I am trying to create some JUnit tests for a method that requires user input. The method under test looks somewhat like the following method: public static int testUserInput() { Scanner keyboard ...
13
votes
6answers
38431 views

raw_input in python without pressing enter

I'm using raw_input in Python to interact with user in shell. c = raw_input('Press s or n to continue:') if c.upper() == 'S': print 'YES' It works as intended, but the user has to press enter i...

Previous Next