用户输入特定条件下的验证 [英] User input verification upon certain condition

查看:71
本文介绍了用户输入特定条件下的验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让用户输入他们的社会安全号码(SSN).我的系统检查使用中的SSN.如果使用了SSN,则说明该SSN正在使用中,并检查信息.但是,不需要他们输入.我如何编写一个脚本,将检查他们是否输入了它,然后验证了它,如果他们没有输入它并且没有或不存在,则让表单进行处理.

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.

有关问题的更新:

我有一个特定的字段值,PHP会在数据库中检查该值.如果该值存在,它将不允许表单处理,并且将要求用户输入一个新条目.但是,我想添加一个例外.我希望能够允许"none","n/a"和该字段的空白字段,无论该值是否存在.但是,当我运行检查脚本时,php显然会接上它.因此,我该怎么做以确保允许这三个特定的条目.

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.

感谢一堆!

推荐答案

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

这篇关于用户输入特定条件下的验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆