您可以将获取参数添加到位置标头或在会话中保存消息标志。像这样:
$sql = "select * from Driver where username=$username and pwd=$pwd";
$driver = mysql_query($sql);
if(!$driver){
header("Location: http://domain.de/login.php?wasredirect=1");
exit();
}
//////// In login.php
if (isset($_GET['wasredirect'])) {
echo "sorry, username isnot correct";
}
或这个:
$sql = "select * from Driver where username=$username and pwd=$pwd";
$driver = mysql_query($sql);
if(!$driver){
header("Location: http://domain.de/login.php");
if (!isset($_SESSION)) {
session_start();
}
$_SESSION['redirect'] = true;
exit();
}
//////// In login.php
if (!isset($_SESSION)) {
session_start();
}
$_SESSION['redirect'] = true;
if (isset($_SESSION['redirect']) &&$_SESSION['redirect'] ) {
echo "sorry, username isnot correct";
unset($_SESSION['redirect']);
}