PHP寄存器错误
我从一个文件中得到了一个非常奇怪的错误,在这两个文件创建过程中,我根本没有更改过这个文件。它工作得很好,只是在我添加了密码匹配项后才开始出现——然后我删除了它,以查看错误是否已解决,并且错误仍然存在 它也出现在我的一些文本框中,在单词之间有BR标记。但是,如果我从文本框中删除错误并添加一些测试数据,脚本仍然会执行它应该执行的操作 我正在观看的教程中的家伙没有得到这些错误PHP寄存器错误,php,xampp,Php,Xampp,我从一个文件中得到了一个非常奇怪的错误,在这两个文件创建过程中,我根本没有更改过这个文件。它工作得很好,只是在我添加了密码匹配项后才开始出现——然后我删除了它,以查看错误是否已解决,并且错误仍然存在 它也出现在我的一些文本框中,在单词之间有BR标记。但是,如果我从文本框中删除错误并添加一些测试数据,脚本仍然会执行它应该执行的操作 我正在观看的教程中的家伙没有得到这些错误 Notice: Undefined index: username in /Applications/XAMPP/xamppf
Notice: Undefined index: username in /Applications/XAMPP/xamppfiles/htdocs/xampp/ooplr/classes/Input.php on line 23
Notice: Undefined index: name in /Applications/XAMPP/xamppfiles/htdocs/xampp/ooplr/classes/Input.php on line 23
register.php
<?php
require_once 'core/init.php';
if(Input::exists()) {
$validate = new Validate();
$validation = $validate->check($_POST, array(
'username' => array(
'required' => true,
'min' => 6,
'max' => 20,
'unique' => 'users'
),
'password' => array(
'required' => true,
'min' => 6
),
'password_again' => array(
'required' => true,
'matches' => 'password'
),
'name' => array(
'required' => true,
'min' => 2,
'max' => 50
)
));
if($validation->passed()) {
echo "passed";
} else {
print_r($validation->errors());
}
}
?>
<form action ="" method= "post">
<div class="field">
<label for= "username">Username</label>
<input type= "text" name= "username" id ="username" value="<?php echo escape(Input::get('username')); ?>" autocomplete="off">
</div>
<div class="field">
<label for="password">Choose a password</label>
<input type="password" name="password" id="password">
<div class="field">
<label for="password_again">Confirm password</label>
<input type="password" name="password_again" id="password_again">
<div class="field">
<label for= "name">Name</label>
<input type= "text" name= "name" value="<?php echo escape(Input::get('name')); ?>" id ="name">
</div>
<input type="submit" value="Register">
</form>
用户名
输入类中的get函数无法检查值是否设置正确:
public static function get($item)
{
if(isset($_POST[$item])) {
return $_POST[$item];
}elseif(isset($_GET[$item])) { //<-- here, was isset($_GET)
return $_GET[$item];
}
return '';
}
公共静态函数get($item)
{
如果(isset($\u POST[$item])){
返回$_POST[$item];
}elseif(isset($\u GET[$item]){/该错误是由于Input::GET('name')缺少值造成的。
在get函数中,它正在查找不存在的name
数组值
public static function get($item) {
if(isset($_POST[$item])) {
return $_POST[$item];
} elseif(isset($_GET[$item])) {
return $_GET[$item];
}
return '';
}
谢谢你的帮助
public static function get($item)
{
if(isset($_POST[$item])) {
return $_POST[$item];
}elseif(isset($_GET[$item])) { //<-- here, was isset($_GET)
return $_GET[$item];
}
return '';
}
public static function get($item) {
if(isset($_POST[$item])) {
return $_POST[$item];
} elseif(isset($_GET[$item])) {
return $_GET[$item];
}
return '';
}