这段程序总是无法在生成的界面中提交数据,总是提示带星号的信息未填完整,但我确实已经填完整了
php
新手求教nbsp;HTML>
include_once("base-class.php");
//新建sae数据库类
$mysql = new SaeMysql();
//获取需要修改的教室ID号传入
$class_id=intval($_GET["class_id"]);
//获取操作标识传入
$action=$_POST["action"];
$action= string::un_script_code($action);
$action= string::un_html($action);
//判断是否修改,如果传入了教室ID,进行数据库查询获取全部内容
if($class_id)
{
$class_value=$mysql->getLine("select * from class where class_id=$class_id");
if(!$class_value)
{
echo "<script>alert('无此教室');history.back();</script>";
exit;
}
}
//如果获取到操作标识,进行录入或者修改操作
if($action=="update")
{
//获取表单传入数据
$old_class_id=$_POST["class_id"];
$class_name=$_POST["class_name"];
$class_number=$_POST["class_number"];
$class_fid=$_POST["class_fid"];
$class_status=$_POST["class_status"];
//传入数据过滤
$old_class_id=intval($old_class_id);
$class_name= string::un_script_code($class_name);
$class_number= string::un_script_code($class_number);
$class_fid=intval($class_fid);
$class_status= intval($class_status);
//检测必填项目
if(!$class_name || !$class_number|| !$roster_status)
{
echo "<script>alert('表单未填完整,带星号为必填项!');history.back();</script>";
exit;
}
//默认参数
$nowtime=date("Y/m/d H:i:s",time());
//如果是修改
if($old_class_id)
{
$sql = "update class set
class_name='$class_name',
class_number='$class_number',
class_fid='$class_fid',
class_status='$class_status',
edittime='$nowtime'
where class_id=$old_class_id";
$mysql->runSql( $sql );
}
else
{
//新增
$sql = "insert into class
(class_name,class_number,class_fid,class_status,addtime,edittime,status)
values
('$class_name','$class_number','$class_status','$class_fid','$nowtime','$nowtime',1)";
$mysql->runSql( $sql );
}
if( $mysql->errno() != 0 )
{
echo "<script>alert('".$mysql->errmsg() ."');history.back();</script>";
exit;
}
else
{
echo "<script>alert('操作成功!');location='roster_add.php?class_id=$old_class_id';</script>";
exit;
}
}
//获取所有教学楼
$building_list=$mysql->getData("select building_name,building_id from building where status=1 order by building_fid asc");
?>
教室添加/修改返回>>
带星号为必填项
回复讨论(解决方案)
1 |
|
这里的$roster_status是在哪里被定义和赋值的?你贴出来的代码中没有,页面上的表单中也没有相关的字段,这当然会触发这个验证了
1 |
|
这里的$roster_status是在哪里被定义和赋值的?你贴出来的代码中没有,页面上的表单中也没有相关的字段,这当然会触发这个验证了 这个确实是,但更改以后还是有问题,请问是不是还有什么地方有问题啊
var_dump($_POST);
1 |
|
这里的$roster_status是在哪里被定义和赋值的?你贴出来的代码中没有,页面上的表单中也没有相关的字段,这当然会触发这个验证了 这个确实是,但更改以后还是有问题,请问是不是还有什么地方有问题啊
你是怎么更改的
1 |
|
这里的$roster_status是在哪里被定义和赋值的?你贴出来的代码中没有,页面上的表单中也没有相关的字段,这当然会触发这个验证了 这个确实是,但更改以后还是有问题,请问是不是还有什么地方有问题啊
你是怎么更改的 改成前面定义过的class_status了
var_dump($_POST); 新手求详细
1.$_POST是存放从表单通过post方式提交过来的数据的变量,使用var_dump来打印出这个变量的内部结构,查看下class_status有没有被表单提交,如果有被提交,那么值是什么
2.
1 |
|
这个地方。请选择教室状态和空闲两个option的值都是0,这是不合理的。如果你选择了这两种状态,那么表单提交的class_status就是0,!逻辑非运算符在计算0时得到结果一样是true,因此会触发错误。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Alipay PHP...

JWT is an open standard based on JSON, used to securely transmit information between parties, mainly for identity authentication and information exchange. 1. JWT consists of three parts: Header, Payload and Signature. 2. The working principle of JWT includes three steps: generating JWT, verifying JWT and parsing Payload. 3. When using JWT for authentication in PHP, JWT can be generated and verified, and user role and permission information can be included in advanced usage. 4. Common errors include signature verification failure, token expiration, and payload oversized. Debugging skills include using debugging tools and logging. 5. Performance optimization and best practices include using appropriate signature algorithms, setting validity periods reasonably,

Session hijacking can be achieved through the following steps: 1. Obtain the session ID, 2. Use the session ID, 3. Keep the session active. The methods to prevent session hijacking in PHP include: 1. Use the session_regenerate_id() function to regenerate the session ID, 2. Store session data through the database, 3. Ensure that all session data is transmitted through HTTPS.

The application of SOLID principle in PHP development includes: 1. Single responsibility principle (SRP): Each class is responsible for only one function. 2. Open and close principle (OCP): Changes are achieved through extension rather than modification. 3. Lisch's Substitution Principle (LSP): Subclasses can replace base classes without affecting program accuracy. 4. Interface isolation principle (ISP): Use fine-grained interfaces to avoid dependencies and unused methods. 5. Dependency inversion principle (DIP): High and low-level modules rely on abstraction and are implemented through dependency injection.

How to automatically set the permissions of unixsocket after the system restarts. Every time the system restarts, we need to execute the following command to modify the permissions of unixsocket: sudo...

How to debug CLI mode in PHPStorm? When developing with PHPStorm, sometimes we need to debug PHP in command line interface (CLI) mode...

Static binding (static::) implements late static binding (LSB) in PHP, allowing calling classes to be referenced in static contexts rather than defining classes. 1) The parsing process is performed at runtime, 2) Look up the call class in the inheritance relationship, 3) It may bring performance overhead.

Article discusses essential security features in frameworks to protect against vulnerabilities, including input validation, authentication, and regular updates.
