loginPDO.php

Gesponsorde koppelingen

PHP script bestanden

  1. loginPDO.php
  2. pdo.php
  3. veilig.php
  4. logout.php

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php  
                      
//DATABASE CONNECTIE, VERANDER NAAR EIGEN GEGEVENS
session_start();  
$host = "localhost";
$username = "root";
$password = "root";  
$database = "paneel";  
$message = "";  
                      
try  {  
    $connect = new PDO("mysql:host=$host; dbname=$database", $username, $password);  
    $connect->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                    
    $username = $_POST["username"];
                    
     //VERANDER NAAAR EIGEN POST NAME
         if(empty($_POST["username"]) || empty($_POST["password"]))  {  
             echo 'All fields required';  
         }

            
          else {
              //QUERY EN ARRAY REGEL 27 NAAR EIGEN GEGEVENS VERANDEREN
             $query = "SELECT * FROM Gebruikers WHERE username = :username AND password = :password";  
              $statement = $connect->prepare($query);  
              $statement->execute(  
                 array(  
                   'username'     =>     $_POST["username"],  
                   'password'     =>     $_POST["password"]  
                     ));
  
                $count = $statement->rowCount();
              
                if($count > 0)  
                {
  
                    //LEIDT NAAR DE JUISTE PAGINA
                    header("Refresh:0; url=veilig.php");
                    //END
                }  
                else {  
                   echo 'Wrong data';
                }  
            }  
        }
  

catch(PDOException $error)  {  
    $message = $error->getMessage();  
}

                      
//SESSION CODE'S, NIET NODIG MAAR HANDIG. ALS JE DIT NIET GEBRUIKT, WERKEN SOMMIGE DINGEN NIET
$username = $_POST['username'];
session_start();
$_SESSION['username'] = $username;

?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.