检查我的代码中的错误,以验证php中的字母数字和空格

I made a form for submit name of the product website in php. I wrote simple code that matches only letters, numbers and whitespace but no special characters. Its working fine for me.

I tried this

if (!preg_match("/^[a-zA-Z0-9 ]*$/",$name))

Could you please found any error or any principle of writing the correct expression that i forgot here in my code .?

In the comments, you mention that is must match a space after the first leter or number So you should modify your preg_match like so:

preg_match("/^[a-zA-Z0-9][a-zA-Z0-9 \t]*$/",$name)

This will match the fist letter or number, then any number of letters, numbers, space and tab.