inlogscript

Gesponsorde koppelingen

PHP script bestanden

  1. inlogscript

« Lees de omschrijving en reacties

index.php:

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
<?
session_start();

include ("config.php");

if(!isset($_SESSION['ID']))
{

    if($_SERVER['REQUEST_METHOD'] != 'POST')
    {

        $query = mysql_query("SELECT * FROM gebruikers WHERE naam = '" . $_POST['gebruiker'] . "' AND pass = '" . md5($_POST['pass']) . "'");
        $resultaat = mysql_num_rows($query);

        if(empty($resultaat))
        {

            echo "<script>alert('Foutieve login.'); document.location.href=('index.php')</script>";
        }

        else
        {
            while($rij = mysql_fetch_assoc($query))
            {

                $id = $rij['id'];
            }

                header("location: index.php");
                $_SESSION['ID'] = $id;
        }
    }

    else
    {
        include("errors.php");
?>

<form method="POST">
<input type="hidden" value="1" name="inloggen">
Gebruikersnaam: <input type="text" name="gebruiker" maxlength="15"><br>
Wachtwoord: <input type="password" name="pass"><br><br>

<input type="Submit" value="Login"><br>
<a href="registreer.php">Registreer</a><br>
</form>
<?
}
}

else
{
header('location: home.php');
}
?>

registreer.php:
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
55
56
57
58
59
60
61
62
63
<?
error_reporting(E_ALL);

include("config.php");

if($_SERVER['REQUEST_METHOD'] == 'POST')
{

?>

<form method="POST">
<input type="hidden" value="1" name="reg_gebr">
<b>Gebruikersnaam:</b><br>
<input type="text" name="naam" maxlength="20"> (Maximum 20 tekens)<br>

<b>Email:</b><br>
<input type="text" name="email" maxlength="125"><br>

<b>Wachtwoord:</b><br>
<input type="password" name="pass"> (Minimum 5 tekens)<br>

<b>Bevestig wachtwoord:</b><br>
<input type="password" name="pass2"><br><br>

<input type="Submit" value="Registreer">
<input type="button" value="Annuleer" OnClick="history.go(-1)">
</form>
<?
}
else
{
    if(!empty($_POST['naam']) AND !empty($_POST['email']) AND !empty($_POST['pass']) AND !empty($_POST['pass2']))
    {

        $resultaat = mysql_result(mysql_query("SELECT COUNT(1) FROM gebruikers WHERE naam = '" . $_POST['naam'] . "'"),0);
        if(!empty($resultaat))
        {

            echo "<script>alert('Gebruikersnaam is al in gebruik.'); history.go(-1)</script>";
        }

        else
        {
            if(strlen($_POST['pass']) > 4)
            {

                echo "<script>alert('Wachtwoord te kort.'); history.go(-1)</script>";
            }

            else
            {
                if($_POST['pass'] != $_POST['pass2'])
                {

                    echo "<script>alert('Wachtwoorden zijn niet hetzelfde.'); history.go(-1)</script>";
                }

                else
                {
                    mysql_query("INSERT INTO gebruikers (naam,pass,email) VALUES
                    ('"
. $_POST['naam'] . "','" . $_POST['pass'] . "','" . md5($_POST['pass']) . "')") or die(mysql_error());
                    header('location: index.php?error=2');
                }
            }
        }
    }

    else
    {
        echo "<script>alert('Gelieve alles in te vullen'); history.go(-1)</script>";
    }
}

?>

config.php:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
<?
$hostname
= "..."; //MySQL Hostname
$username = "..."; //MySQL gebruikersnaam
$password = "..."; //MySQL Wachtwoord
$database = "..."; //MySQL Database

mysql_connect($hostname,$username,$password) or die(mysql_error());
mysql_select_db($database);
?>

home.php:
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
<?
include("config.php");

if(isset($_SESSION['ID'])) {
    //Hier de inhoud...
} else {
    header('location: index.php?error=1');
}
[
/code]
errors.php:
[
code]
[
code]<?
if(isset($_GET['error'])) {
if($_GET['error'] == 0) {
echo "<b><font color=\"green\">Gefeliciteerd. U kunt dit systeem nu gebruiken.</font></b>";
}
elseif($_GET['error'] == 1) {
echo "<b><font color=\"red\">U bent niet ingelogd.</font></b>";
}
elseif($_GET['error'] == 2) {
<
b><font color=\"blue\">U bent succesvol geregistreerd. U kunt nu inloggen.</font></b>";
}
}
[
/code]
SQL:
(
Met phpMyAdmin):
[
code]
CREATE TABLE `login` (
`id` int NOT NULL auto_increment,
`naam` varchar(20) NOT NULL,
`pass` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
)
ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
[
/code]
(
Of heb je geen phpMyAdmin?):
[
code]
[
code]<?
include("config.php");

mysql_query("CREATE TABLE `login` (
`id` int NOT NULL auto_increment,
`naam` varchar(20) NOT NULL,
`pass` varchar(255) NOT NULL,
`email` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;"
) or die(mysql_error());
header('location: index.php?error=0'); ?>

 
 

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.