如何在 php 中编辑 id 代码值


How to edit id code value in php

>我在表单邮件中使用了下面的代码。但是我想更改代码,因此用户输入可以是数字和字母以及其他内容,因此它可以是任何长度。希望有人可以帮助完成 2 个更改。谢谢。

if(isset($_POST['idcode'])) {
    if(strlen($_POST['idcode']) != 8 || !is_numeric($_POST['idcode'])) {
        $error = "input must contain 8 numbers";
    } else {
如果你想

让它接受一切,请这样做:

if(isset($_POST['idcode'])) {
// code here
} else {
    $error = "you must set the idcode"; // can be changed
}

但是,如果您想检查 8 及以上的长度,请执行以下操作:

if(isset($_POST['idcode'])) {
    if(strlen($_POST['idcode']) >= 8) {
        // code here
    } else {
       $error = "you need to have at least 8 chars"; // can change
    }
} else {
    $error = "you must set the idcode"; // can be changed
}