您可以添加获取参数到位置标题或保存会话中的消息标志。就像这样:
$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']);
}
urlencode $ message – Kevin
@Kevin,怎么样?你能说更多的话吗? – doniyor
http://php.net/manual/en/function.urlencode.php应该可以帮到你。将它附加到URL时。确保在另一端使用urldecode()。 – Kevin