Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $data=array("user1"=>array("url"=>"page1.php","password"=>"12345"),
- "user2"=>array("url"=>"page2.php","password"=>"12345"),
- "user3"=>array("url"=>"page3.php","password"=>"12345")
- );
- if(isset($_POST['username']) && isset($_POST['password'])) {
- $user = strtolower($_POST['username']);
- $pass = strtolower($_POST['password']);
- if($data[$user]['password'] == $pass) {
- $_SESSION['username'] = $user . " " . $pass;
- header('Location: ' . $data[$user]['url']);
- } else {
- echo '<script type="text/javascript">window.onload = function() { document.getElementById("loginError").innerHTML = "' . "Invalid login details. Please try again." . '"; }</script>';
- logIn();
- }
- } else {
- logIn();
- }
- ?>
- if(isset($_POST['username']) && !empty($_POST['username']) &&
- isset($_POST['password']) && !empty($_POST['password']) ) {
- //Do code here
- }
- else
- {
- logIn();
- }
- ...
- $user = strtolower(trim($_POST['username']));
- $pass = strtolower(trim($_POST['password']));
- if($user !== '' && $pass !== '') {
- //continue with login logic
- if($data[$user]['password'] === $pass) {
- ...
- }
- else{
- //print error
- }
- session_start();
- $data=array("user1"=>array("url"=>"page1.php","password"=>"12345"),
- "user2"=>array("url"=>"page2.php","password"=>"12345"),
- "user3"=>array("url"=>"page3.php","password"=>"12345")
- );
- if (!empty($_POST['username'] && !empty($_POST['password'])) {
- $user = strtolower($_POST['username']);
- $pass = strtolower($_POST['password']);
- if (isset($data[$user]) && $data[user]['password'] == $pass) {
- $_SESSION['username'] = $user . ' ' . $pass;
- header("Location: " . $daa[$user]['url']);
- } else {
- echo '<script type="text/javascript">window.onload = function() { document.getElementById("loginError").innerHTML = "' . "Invalid login details. Please try again." . '"; }</script>';
- logIn();
- }
- } else {
- logIn();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement