我的问题是我想创建一个登录屏幕,注册表单和丢失的密码表单。我设法在登录屏幕上创建了一条错误消息,但是在注册表单中执行时却没有这样做。 所以我的问题是,我怎样才能将我的注册表单参数添加到函数auth中,它将为注册表单执行相同操作?php登录的一些问题
case "authent":
auth();
break;
function auth(){
global $myurl;
$errors=array();
$username="";
$passwd="";
if (isset($_POST['username']) && $_POST['username']!="") {
$username=$_POST['username'];
} else {
$errors[]="Username missing!";
}
if (isset($_POST['passwd']) && $_POST['passwd']!="") {
$passwd=$_POST['passwd'];
} else {
$errors[]="Password missing, fill the blank!";
}
if (empty($errors)){
// no errors, check the information
if ($username=="user" && $passwd=="password"){
// correct information
header("Location: $myurl?mode=success");
} else {
// wrong information, back to login.html
$errors[]="Vale info, proovi uuesti.";
include("view/login.html");
}
} else {
// errors with messages
include("view/login.html");
}
}
你为什么要包括的login.php页面?如果有任何错误,那么你在同一页面上。只显示错误(s)。 – user3470953
感谢您指出,我的计划是为错误弹出一个错误,这只是一个暂时的事情。你有什么想法如何让函数适用于多种情况? – user3225423