我想在登錄後重定向到同一頁面,但我需要像if username and password come from index.php
這樣的頁面將重定向到dashboard.php,else it will redirect on the same page (exmple.php)
。如何在登錄後用用戶名重定向到同一頁面PHP
的login.php:
<?php
include ('include/connection.php');
if (isset($_POST['loginform'])) {
session_start();
$email = trim(mysql_escape_string($_POST['email']));
$passwords = trim(mysql_escape_string($_POST['pwd']));
$password = md5($passwords);
$verify_query = "SELECT * FROM end_user WHERE (email='$email' AND password='$password')";
verify_result = mysqli_query($con, $verify_query);
if(!$verify_result){
echo '<h2>Couldnot Process your request Please try to login after some time. </h2>';
}
if (@mysqli_num_rows($verify_result) == 1) {
$_SESSION = mysqli_fetch_array($verify_result, MYSQLI_ASSOC);
header("Location: dashboard.php");
}
else {
echo '<h2 style="color:#CC3300;">Incorrect Credentials, You need to register <a href="signup.php" style="font-size:20px;" class="btn btn-primary">Here</a></h2>';
}
mysqli_close($con);
}
?>
的index.php:
session_start(); // starts the session
$_SESSION['url'] = $_SERVER['REQUEST_URI'];
而且我用同樣的代碼在example.php
,這樣我就可以在$_SESSION
得到URL。
您可以使用頭,如果沒有HTML已發送到客戶端 – NoLiver92
你的mysql混合的API也是 –
並且不要**在實時環境中使用此代碼;這完全不安全。 –