I want to check that a user input in textbox doesnot contains any special character. how can i validate text box without using any javascript/Jquery
Try this, $name
is the user input,
if(preg_match('/[^a-z0-9 _]+/i', $name)) {
// preg_match will return true if it finds
// a character *other than* a-z, 0-9, space and _
// *anywhere* inside the string
}