Skip to content

Instantly share code, notes, and snippets.

@arif98741
Created January 11, 2019 15:50
Show Gist options
  • Save arif98741/050b43226e8c3ed304fa66f336552bf3 to your computer and use it in GitHub Desktop.
Save arif98741/050b43226e8c3ed304fa66f336552bf3 to your computer and use it in GitHub Desktop.
Login Redirection
<?php
session_start();
//check user is logged in or not
if (!isset($_SESSION['login'])) {
header("location: login.php");
}
echo "sit kale ato thanda lage ken?";
?>
<?php
//check user is logged in or not
session_start();
if (isset($_SESSION['login'])) {
header("location: index.php");
}
$con = mysqli_connect('localhost', 'root', '', 'b');
if (isset($_POST['submit'])) {
$email = $_POST['email'];
$passward = $_POST['passward'];
$sql = "SELECT * FROM bb WHERE email='$email' AND passward='$passward'";
$query = mysqli_query($con, $sql);
if (mysqli_num_rows($query) > 0) {
//set session
$_SESSION['login'] == TRUE;
header("location: home.php");
} else {
header("location: login.php");
}
} else {
}
?>
<html>
<form action="login.php" method="POST" >
Email : <input type="email" name="email"/>
Passward : <input type="passward" name="passward"/>
<input type="submit" value="submit" name="submit"/>
</form>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment