Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php //Start the Session
- session_start();
- require('connect.php');
- //3. If the form is submitted or not.
- //3.1 If the form is submitted
- if (isset($_POST['form-username']) and isset($_POST['form-password'])){
- //3.1.1 Assigning posted values to variables.
- $username = $_POST['form-username'];
- $password = $_POST['form-password'];
- }else{
- echo "Nu ai introdus username sau parola.";
- }
- $tip = "";
- //3.1.2 Checking the values are existing in the database or not
- $query = "SELECT * FROM conturi WHERE username='$username' and password='$password'";
- $result = mysqli_query($connection, $query) or die(mysqli_error($connection));
- if (mysqli_num_rows($result) > 0) {
- // output data of each row
- while($row = mysqli_fetch_assoc($result)) {
- $id = $row['id'];
- $tip = $row["tip"];
- }
- }else{
- echo "Datele de logare sunt invalide.";
- }
- if($tip == 'admin'){
- $_SESSION['loggedIn'] = true;
- header("location:profile_admin.php?id=$id");
- }else if($tip == 'user'){
- $_SESSION['loggedIn'] = true;
- header("location:profile.php?id=$id");
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement