ログイン後も同じページにリダイレクトしたいが、のような条件が必要な場合、ページはダッシュボードにリダイレクトされる。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'];
そして、私は$_SESSION
でURLを取得することができるように、私は、example.php
で同じコードを使用していました。あなたのindex.phpログインフォームから
HTMLコードを使用すると、mysqlのAPIを混合している – NoLiver92
クライアントに送信されていない場合は、ヘッダーを使用することができます –
も**このコードは実際の環境では使用しません。それは全く危険です。 –