User input verification upon certain condition

谁都会走 提交于 2020-01-06 12:48:06

问题


I am lettings users enter their Social Security number (SSN). My system checks for SSNs in use. If the SSN is in use it says that the SSN is in use and check info. However, they are not required to enter it. How do i write a script that will check if they entered it and then verify it and if they don't enter it and they NOne or n/a then let the form process.

Update on question:

I have a certain field value that the php checks for in the DB. If the value exists, it will not let a form process and will require the user to enter a new entry. However, I want to add an exception. I want the ability to allow "none", "n/a", and blank field for this field regardless if the value exists or not. But when i run the check script, the php obviously picks up on it. So what can i do to make sure those three particular entries are allowed.

Thanks a bunch!


回答1:


if (!empty($_POST['ssn']) && $_POST['ssn'] != "none" && $_POST['ssn'] != "n/a") {
    //your code to validate the ssn as one was entered
}


来源:https://stackoverflow.com/questions/4814227/user-input-verification-upon-certain-condition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!