gpt4 book ai didi

php - PHP的 fatal error

转载 作者:行者123 更新时间:2023-11-29 07:05:04 26 4
gpt4 key购买 nike

我正在制作一个管理面板,并且正在制作一个用于添加用户的表单。我的代码如下:

        <form class="form-horizontal">
<fieldset>

<!-- Form Name -->
<legend>Add user</legend>

<!-- Prepended text-->
<div class="form-group">
<label class="col-md-4 control-label" for="newuser">Username</label>
<div class="col-md-4">
<div class="input-group">
<span class="input-group-addon">@</span>
<input id="newuser" name="newuser" class="form-control" placeholder="Username" type="text" required="">
</div>
<p class="help-block">Put the new users username here</p>
</div>
</div>

<!-- Password input-->
<div class="form-group">
<label class="col-md-4 control-label" for="userpw">New user password</label>
<div class="col-md-4">
<input id="userpw" name="userpw" type="password" placeholder="Password" class="form-control input-md" required="">
<span class="help-block">Enter new user's password here!</span>
</div>
</div>

<!-- Select Basic -->
<div class="form-group">
<label class="col-md-4 control-label" for="permissions">Choose permissions</label>
<div class="col-md-4">
<select id="permissions" name="permissions" class="form-control">
<option value="1">System administrator</option>
<option value="2">Editor</option>
<option value="3">Developer</option>
<option value="4">Normal user</option>
</select>
</div>
</div>

<!-- Button -->
<div class="form-group">
<label class="col-md-4 control-label" for="btn_send">Send request to server</label>
<div class="col-md-4">
<button id="btn_send" name="btn_send" class="btn btn-primary">Send it!</button>
</div>
</div>

</fieldset>
</form>
<?php
$newuser = $_GET['newuser'];
$userpw = $_GET['userpw'];
$permission = $_GET['permissions'];


if(isset($newuser and $userpw and $permission) {
$sql = "INSERT INTO users(username,userpw,permission)VALUES('$newuser', '$userpw','$permission')";

mysql_query($sql);
}
else {
echo "error";}

我得到:

fatal error :无法在第 95 行 C:\xampp\htdocs\lumino\usermanagement.php 中的表达式结果上使用 isset()(您可以使用“null !== 表达式”代替)

无论如何我都无法修复它,玩了大约 5 个小时。它正在执行 $_GET 方法,所以我得到的网址如下:

mysite.com/usermanagement.php?newuser=Berkay&userpw=18042003&permissions=3&btn_send=

最佳答案

使用isset,您不能在其中包含多个项目:

if(isset($newuser and $userpw and $permission) {

需要成为:

if(isset($newuser) && isset($userpw) && isset($permission)) {

或者:

if(isset($newuser, $userpw, $permission)) {

关于php - PHP的 fatal error ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42027533/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com