Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if($_SERVER["REQUEST_METHOD"] == "POST") {
- // Connect to server and select databse.
- mysql_connect("$host", "$username", "$password")or die("cannot connect");
- mysql_select_db("$db_name")or die("cannot select DB");
- // username and password sent from form
- $username=$_POST['username'];
- $password=$_POST['password'];
- // To protect MySQL injection (more detail about MySQL injection)
- $username = stripslashes($username);
- $password = stripslashes($password);
- $username = mysql_real_escape_string($username);
- $password = mysql_real_escape_string($password);
- $sql="SELECT * FROM $tbl_name WHERE username='$username' and password='$password'";
- $result=mysql_query($sql);
- // Mysql_num_row is counting table row
- $count=mysql_num_rows($result);
- // If result matched $myusername and $mypassword, table row must be 1 row
- if($count==1){
- // Register $username, $password and redirect to file "index.php"
- session_register("username");
- session_register("password");
- if($username == "vuk" || $username == "petar" || $username == "jelena" || $username == "irena" || $username == "test") {
- $_SESSION['loggedin'] = true;
- $_SESSION['username'] = $username;
- echo '
- <script type="text/javascript">
- window.location = "http://heroindetoxeurope.com/crm/vorobjev/index.php"
- </script>';
- }
- else if ($username == "admin" || $username == "dusan"){
- $_SESSION['loggedin'] = true;
- $_SESSION['username'] = $username;
- echo '
- <script type="text/javascript">
- window.location = "http://heroindetoxeurope.com/crm/vorobjev/index1.php"
- </script>';
- }
- }
- else {
- $error = "Pogresna kombinacija korisnickog imena i lozinke!";
- }
- }
- ?>
- <html>
- <head>
- <title>User Login - Management system</title>
- <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
- <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"/>
- <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
- <link rel="stylesheet" type="text/css" href="css/login.css"/>
- <link rel="shortcut icon" type="image/ico" href="images/fav.ico"/>
- </head>
- <body>
- <div class="container" style="margin-top: 200px;">
- <?php if(isset($smsg)){ ?>
- <div class="alert alert-success" role="alert">
- <?php echo $smsg; ?>
- </div>
- <?php } ?>
- <?php if(isset($fmsg)){ ?>
- <div class="alert alert-danger" role="alert">
- <?php echo $fmsg; ?>
- </div>
- <?php } ?>
- <form name="login-form" class="login-form" method="post">
- <div class="header">
- <h1 style="text-align: center;">Dr Vorobjev Management System</h1>
- </div>
- <div class="content">
- <input name="username" type="text" class="input username" placeholder="Username" name="username" required="" />
- <div class="user-icon"></div>
- <input name="password" type="password" class="input password" placeholder="Password" name="password" required="" />
- <div class="pass-icon"></div>
- </div>
- <div class="footer">
- <button class="button" type="submit">Login</button>
- </div>
- </form>
- <div style = "font-size:11px; color:#cc0000; margin-top:10px; text-align: center;"><?php echo $error; ?></div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement