Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if(isset($_POST['submit'])){
- $con = mysqli_connect("localhost","root","","imetrics");
- $username = $_POST['username'];
- $password = $_POST['password'];
- $user = mysqli_query($con, "SELECT * FROM user WHERE password='$password' AND username='$username'")or die("Cannot connect");
- $count = mysqli_num_rows($user);
- if($count > 0) {
- $row = mysqli_fetch_assoc($user);
- if($row['usertype'] == 'Client'){
- $_SESSION['username'] = $_POST['username'];
- header("location:a.php");
- }
- else{
- $_SESSION['username'] = $_POST['username'];
- header("location:takesurvey.php");
- }
- }
- else{
- echo '<script language="javascript">';
- echo 'alert("Wrong username/password")';
- echo '</script>';
- }
- }
- ?>
- <html>
- <head></head>
- <body>
- <form method="POST" >
- <div class="row form-group">
- <div class="col-sm-12">
- <input type="text" name="username" id="username" class="form-control" placeholder="Username">
- </div>
- </div>
- <div class="row form-group">
- <div class="col-sm-12">
- <input type="password" name="password" id="password" class="form-control" placeholder="Password">
- </div>
- </div>
- <div class="row form-group">
- <div class="col-sm-12">
- <input type="submit" name="submit" class="form-control btn btn-primary" value="Login">
- </div>
- </div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement