Home > php教程 > php手册 > 使用php验证复选框有效性的示例

使用php验证复选框有效性的示例

WBOY
Release: 2016-06-06 20:26:27
Original
1198 people have browsed it

本文介绍一个简单的php通过代码验证复选框值的有效性,有需要的可以参考一下

验证复选框的php代码,,如下:

复制代码 代码如下:

/** 
* 在php中验证复选框的有效性 
*/
$value = 'yes'; 
echo " 验证数据"; 

if (isset($_POST['subscribe'])) { 
    if ($_POST['subscribe'] == $value) { 
        $subscribed = true; 
    } else { 
        $subscribed = false; 
        print '提交的复选框值无效。'; 
    } 
} else { 
    $subscribed = false; 


if ($subscribed) { 
    print '验证有效!'; 
} else { 
    print '验证无效!'; 
}

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template