Ledensysteem [+ EXTRA!]

Gestart doorSkytop7 reacties42 weergaven

8 berichten · pagina 1 van 1

Skytop

Lid · Topicstarter

Berichten
1.101
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Hallo iedereen,

Ik ging nog eens PHP leren.
En zo heb ik mijn allereerste ledensysteem gescript.

MySQL gegevens.

- Maak een database aan
- Maar een tabel aan (naam tabel: users) met 5 vakken.

Vakken gegevens:

Vak 1;
Naam: ID
(INT)
Index: Primary
A_I

Vak 2:
Naam: name
(VARCHAR(25))

Vak 3:
Naam: username
(VARCHAR(25))

Vak 4:
Naam: password
(VARCHAR(25))

Vak 5:
date
(DATE)

RAW DATA:
Spoiler tonen
# Kolom Type Collatie Attributen Null Standaardwaarde Extra Actie
1 id int(11) Nee Geen AUTO_INCREMENT Veranderen Veranderen Verwijderen Verwijderen Meer Geef meer acties weer
2 name varchar(25) latin1_swedish_ci Nee Geen Veranderen Veranderen Verwijderen Verwijderen Meer Geef meer acties weer
3 username varchar(25) latin1_swedish_ci Nee Geen Veranderen Veranderen Verwijderen Verwijderen Meer Geef meer acties weer
4 password varchar(25) latin1_swedish_ci Nee Geen Veranderen Veranderen Verwijderen Verwijderen Meer Geef meer acties weer
5 date date Nee Geen Veranderen Veranderen Verwijderen Verwijderen Meer Geef meer acties weer
Index.php [Hier kan de gebruiker inloggen, en staat eronder een link als je nog geen account hebt.]

Index .php [Engels]:

<html>
<head>
<title>titel<title>
</head>
<body>
    <form action="login.php" method="POST">
     Username:   <input type="text" name="username" /><br />
     Password:   <input type="password" name="password" /><br />    
                 <input type="submit" value="Log in" />
    </form><p>
        
    <a href="register.php">Dont got a account?</a>
</body>
</html>


Index.php [Nederlands]:

<html>
<head>
<title>titel</title>
</head>
<body>
    <form action="login.php" method="POST">
     Gebruikersnaam:   <input type="text" name="username" /><br />
     Wachtwoord:   <input type="password" name="password" /><br />    
                 <input type="submit" value="Inloggen" />
    </form><p>
        
    <a href="register.php">Heb je nog geen account?</a>
</body>
</html>


Login.php [ENGELS]:

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
{[/COLOR]
    [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"username"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"password"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Cant connect with the database."[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"databasenaam"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Cant find database."[/COLOR][COLOR= #007700]);[/COLOR]
    
    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users  WHERE username=$username"[/COLOR][COLOR= #007700]);[/COLOR]
    
    [COLOR= #0000BB]$numrows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700]!=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700])
    {[/COLOR]
        [COLOR= #FF8000]//code to login[/COLOR]
        [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
        {[/COLOR]
           [COLOR= #0000BB]$dbusername[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
           [COLOR= #0000BB]$dbpassword[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];
           
        }[/COLOR]
        [COLOR= #FF8000]//check if they match![/COLOR]
        [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbusername[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
        {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<div align=center><h1>Welcome to AnimeFAN.nl!</h1><br><a href=logout.php>Logout</a></div>"[/COLOR][COLOR= #007700];[/COLOR]
            [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]=[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700];
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Incorrect Password!"[/COLOR][COLOR= #007700];
        }
            
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"That User doenst exist!"[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Please enter a username ans a password."[/COLOR][COLOR= #007700]);[/COLOR]
?>


Login.php [NEDERLANDS]:

[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]

[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
{[/COLOR]
    [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"gebruikersnaam"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"kan niet verbinden met de database."[/COLOR][COLOR= #007700]);[/COLOR]
    [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"databasenaam"[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Kan database niet vinden."[/COLOR][COLOR= #007700]);[/COLOR]
    
    [COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * FROM users  WHERE username=$username"[/COLOR][COLOR= #007700]);[/COLOR]
    
    [COLOR= #0000BB]$numrows[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_num_rows"]mysql_num_rows[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]);[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$numrows[/COLOR][COLOR= #007700]!=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700])
    {[/COLOR]
        [COLOR= #FF8000]//code to login[/COLOR]
        [URL="http://www.php.net/while"]while[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$row[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]))
        {[/COLOR]
           [COLOR= #0000BB]$dbusername[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
           [COLOR= #0000BB]$dbpassword[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]];
           
        }[/COLOR]
        [COLOR= #FF8000]//check if they match![/COLOR]
        [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$dbusername[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])
        {[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<div align=center><h1>Welkom op sitenaam.nll!</h1><br><a href=logout.php>Uitloggen</a></div>"[/COLOR][COLOR= #007700];[/COLOR]
            [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]=[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700];
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
        [COLOR= #007700]{[/COLOR]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Incorrect wachtwoord!"[/COLOR][COLOR= #007700];
        }
            
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
        [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Deze gebruiker bestaat niet!"[/COLOR][COLOR= #007700]);
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Vul a.u.b een gebruikersnaam en wachtwoord in."[/COLOR][COLOR= #007700]);[/COLOR]
?>


logout.php [ENGELS]:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]])
{[/COLOR]
 [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Youve been logged out. Click <a href=index.php>here</a> to go back."[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"You must be logged in!"[/COLOR][COLOR= #007700]);[/COLOR]

?>


Logout.php [NEDERLANDS]:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]])
{[/COLOR]
 [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je bent uitgelogd. Klik <a href=index.php>hier</a> om terug te gaan."[/COLOR][COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL]
    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Je moet wel ingelogd zijn!"[/COLOR][COLOR= #007700]);[/COLOR]

?>


Register.php [ENGELS]:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1>Register</h1>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$submit[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #FF8000]//form data[/COLOR]
[COLOR= #0000BB]$fullname[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fullname[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$repeatpassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]repeatpassword[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$date[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$submit[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [COLOR= #FF8000]//check for existance[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$fullname[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$repeatpassword[/COLOR][COLOR= #007700])
    {[/COLOR]
       
        [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$repeatpassword[/COLOR][COLOR= #007700])
        {[/COLOR]
            [COLOR= #FF8000]//check char length of username and fullname[/COLOR]
            [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700]||[/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fullname[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700])
            {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Lenth of username or fullname is too long!"[/COLOR][COLOR= #007700];
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
                [COLOR= #FF8000]//check password length[/COLOR]
                [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700]||[/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])<[/COLOR][COLOR= #0000BB]6[/COLOR][COLOR= #007700])
                {[/COLOR]
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Password must be between 6 and 25 characters."[/COLOR][COLOR= #007700];
                }[/COLOR]
                [URL="http://www.php.net/else"]else[/URL]
                [COLOR= #007700]{[/COLOR]
                    [COLOR= #FF8000]//register the user![/COLOR]
                     [COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]);[/COLOR]
                     [COLOR= #0000BB]$repeatpassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$repeatpassword[/COLOR][COLOR= #007700]);[/COLOR]
        
                    [COLOR= #FF8000]//open database[/COLOR]
                    [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"username"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"password"[/COLOR][COLOR= #007700]);[/COLOR]
                    [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"database"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//select database (db)[/COLOR]
                    
                    [COLOR= #0000BB]$queryreg[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
                    INSERT INTO users VALUES (,$fullname,$username,$password,$date) 
                    
                    "[/COLOR][COLOR= #007700]);[/COLOR]
                    
                    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"You have been registered! <a href=index.php>Go Back to Login!</a>"[/COLOR][COLOR= #007700]);
                                    }
            }
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Your passwords do <b>not</b> match!"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Please fill in <b>all</b> fields!"[/COLOR][COLOR= #007700];
}[/COLOR]
?>
<html>
<form action="register.php" method="POST">
    <table>
        <tr>
            <td>
            Your Full Name;
            </td>
            <td>
            <input type="text" name="fullname" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$fullname[/COLOR][COLOR= #007700];[/COLOR] ?>">
            </td>
        </tr>
           <tr>
            <td>
            Choose a Username:
            </td>
            <td>
            <input type="text" name="username" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700];[/COLOR] ?>">
            </td>
        </tr>
           <tr>
            <td>
            Choose a Password:
            </td>
            <td>
            <input type="password" name="password">
            </td>
        </tr>
           <tr>
            <td>
            Repeat Password:
            </td>
            <td>
            <input type="password" name="repeatpassword">
            </td>
        </tr>
    </table>
    <p>
    <input type="submit" name="submit" value="register">
</form>
</html>


register.php [NEDERLANDS]:

[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"<h1>Registreer</h1>"[/COLOR][COLOR= #007700];[/COLOR]

[COLOR= #0000BB]$submit[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]submit[/COLOR][COLOR= #007700]];[/COLOR]

[COLOR= #FF8000]//form data[/COLOR]
[COLOR= #0000BB]$fullname[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]fullname[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$username[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$repeatpassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strip_tags"]strip_tags[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]repeatpassword[/COLOR][COLOR= #007700]]);[/COLOR]
[COLOR= #0000BB]$date[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Y-m-d"[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$submit[/COLOR][COLOR= #007700])
{[/COLOR]
    
    [COLOR= #FF8000]//check als gebruiker al bestaat[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$fullname[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]&&[/COLOR][COLOR= #0000BB]$repeatpassword[/COLOR][COLOR= #007700])
    {[/COLOR]
       
        [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]==[/COLOR][COLOR= #0000BB]$repeatpassword[/COLOR][COLOR= #007700])
        {[/COLOR]
            [COLOR= #FF8000]//check voor lengte van gebruikersnaam en volledige naam[/COLOR]
            [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$username[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700]||[/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$fullname[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700])
            {[/COLOR]
                [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Lengte van gebruikersnaam en/of volledige naam is te lang!"[/COLOR][COLOR= #007700];
            }[/COLOR]
            [URL="http://www.php.net/else"]else[/URL]
            [COLOR= #007700]{[/COLOR]
                [COLOR= #FF8000]//check voor wachtwoord lengte[/COLOR]
                [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])>[/COLOR][COLOR= #0000BB]25[/COLOR][COLOR= #007700]||[/COLOR][URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])<[/COLOR][COLOR= #0000BB]6[/COLOR][COLOR= #007700])
                {[/COLOR]
                    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je wachtwoord moet tussen 6 en 25 karakters zijn."[/COLOR][COLOR= #007700];
                }[/COLOR]
                [URL="http://www.php.net/else"]else[/URL]
                [COLOR= #007700]{[/COLOR]
                    [COLOR= #FF8000]//registreer de gebruiker![/COLOR]
                     [COLOR= #0000BB]$password[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700]);[/COLOR]
                     [COLOR= #0000BB]$repeatpassword[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$repeatpassword[/COLOR][COLOR= #007700]);[/COLOR]
        
                    [COLOR= #FF8000]//verbinden met database [/COLOR]
                    [COLOR= #0000BB]$connect[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"localhost"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"gebruikersnaam"[/COLOR][COLOR= #007700],[/COLOR][COLOR= #DD0000]"wachtwoord"[/COLOR][COLOR= #007700]);[/COLOR]
                    [URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"databasenaam"[/COLOR][COLOR= #007700]);[/COLOR] [COLOR= #FF8000]//database selecteren[/COLOR]
                    
                    [COLOR= #0000BB]$queryreg[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"
                    INSERT INTO users VALUES (,$fullname,$username,$password,$date) 
                    
                    "[/COLOR][COLOR= #007700]);[/COLOR]
                    
                    [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Je bent geregistreerd! <a href=index.php>Ga terug en log in!</a>"[/COLOR][COLOR= #007700]);
                                    }
            }
        }[/COLOR]
        [URL="http://www.php.net/else"]else[/URL]
            [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Je wachtwoorden zijn niet hetzelfde!"[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL]
        [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]"Vul a.u.b alle velden in!"[/COLOR][COLOR= #007700];
}[/COLOR]
?>
<html>
<form action="register.php" method="POST">
    <table>
        <tr>
            <td>
            Je volledige naam:
            </td>
            <td>
            <input type="text" name="fullname" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$fullname[/COLOR][COLOR= #007700];[/COLOR] ?>">
            </td>
        </tr>
           <tr>
            <td>
            Kies een gebruikersnaam:
            </td>
            <td>
            <input type="text" name="username" value="[COLOR= #0000BB]<?php[/COLOR] [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700];[/COLOR] ?>">
            </td>
        </tr>
           <tr>
            <td>
            Kies een wachtwoord:
            </td>
            <td>
            <input type="password" name="password">
            </td>
        </tr>
           <tr>
            <td>
            Herhaal wachtwoord:
            </td>
            <td>
            <input type="password" name="repeatpassword">
            </td>
        </tr>
    </table>
    <p>
    <input type="submit" name="submit" value="register">
</form>
</html>


Vragen over het script?
Stel maar smile.

Je mag dit script gebruiken.
Er staat geen copyright in of op. En ik hoop ook dat je respect voor het script en niet gaat zeggen dat het van jou is!

Functies in dit script:
- Inloggen
- Registreren
- Uitloggensmile
Live voorbeeld: animefan.nl

Etxra!

Anoniem Emails sturen!
Spoiler tonen
Ik heb het contactscript van Daiman (op one2xs) gepakt.
En deze een beetje omgebouwd zodat je ook zelf kan kiezen naar wie je stuurt.
Live voorbeeld: http://www.animefan.nl/anoniem.php

SCRIPT:
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #FF8000]/**
 * @author Semmiiee (& Daiman)
 * @copyright 2011
 */[/COLOR]


?>
[COLOR= #0000BB]<?php
$email[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]naam[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$cmail[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #0000BB]$email[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"onderwerp"[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"bericht"[/COLOR][COLOR= #007700]])) {[/COLOR]
[COLOR= #0000BB]$fout[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #0000BB]0[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #0000BB]$fouten[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"naam"[/COLOR][COLOR= #007700]])) {[/COLOR]
    [COLOR= #0000BB]$fout[/COLOR][COLOR= #007700]++;[/COLOR]
    [COLOR= #0000BB]$fouten[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"Geen naam ingevoerd!<br />"[/COLOR][COLOR= #007700];
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"onderwerp"[/COLOR][COLOR= #007700]])) {[/COLOR]
    [COLOR= #0000BB]$fout[/COLOR][COLOR= #007700]++;[/COLOR]
    [COLOR= #0000BB]$fouten[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"Geen onderwerp ingevoerd!<br />"[/COLOR][COLOR= #007700];
    }[/COLOR]

    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"bericht"[/COLOR][COLOR= #007700]])) {[/COLOR]
    [COLOR= #0000BB]$fout[/COLOR][COLOR= #007700]++;[/COLOR]
    [COLOR= #0000BB]$fouten[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"Geen bericht ingevoerd!<br />"[/COLOR][COLOR= #007700];
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"email"[/COLOR][COLOR= #007700]])) {[/COLOR]
    [COLOR= #0000BB]$fout[/COLOR][COLOR= #007700]++;[/COLOR]
    [COLOR= #0000BB]$fouten[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]"Geen email-adres ingevoerd!<br />"[/COLOR][COLOR= #007700];
    }[/COLOR]
    
    [URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$fout[/COLOR] [COLOR= #007700]!=[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]) {[/COLOR]
    ?>
    <form action="" method="POST">
    <table>
<tr>
    <td>
    Verzenden naar:
    </td>
    <td>
    <input type="text" name="naam" />
    </td>
</tr>
<tr>
    <td>
    Onderwerp:
    </td>
    <td>
    <input type="text" name="onderwerp" />
    </td>
</tr>
<tr>
    <td>
    Afkomstig van:
    </td>
    <td>
    <input type="text" name="email" />
    </td>
</tr>
<tr>
    <td>
    Bericht:
    </td>
    <td>
    <textarea name="bericht"></textarea>
    </td>
</tr>
</table>
<input type="submit" value="Verzend Anoniem Bericht" />
    </form>
    <br />
    <b>Niet alles is ingevuld!</b><br /><br />
    [COLOR= #0000BB]<?[/COLOR]
    [URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$fouten[/COLOR][COLOR= #007700];
    }[/COLOR]
    [URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
    [COLOR= #0000BB]$headers[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"From: "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"
Reply-To: "[/COLOR][COLOR= #007700].[/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]email[/COLOR][COLOR= #007700]].[/COLOR][COLOR= #DD0000]"
X-Mailer: PHP/"[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/phpversion"]phpversion[/URL][COLOR= #007700]();[/COLOR]
    [URL="http://www.php.net/mail"]mail[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$cmail[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"onderwerp"[/COLOR][COLOR= #007700]],[/COLOR] [COLOR= #DD0000]"<html>"[/COLOR][COLOR= #007700].[/COLOR][URL="http://www.php.net/nl2br"]nl2br[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]"bericht"[/COLOR][COLOR= #007700]]).[/COLOR][COLOR= #DD0000]"</html>"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$headers[/COLOR][COLOR= #007700]);
    }
}[/COLOR]
[URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
?>
<form action="" method="POST">
<table>
<tr>
    <td>
    Verzenden naar:
    </td>
    <td>
    <input type="text" name="naam" />
    </td>
</tr>
<tr>
    <td>
    Onderwerp:
    </td>
    <td>
    <input type="text" name="onderwerp" />
    </td>
</tr>
<tr>
    <td>
    Afkomstig van:
    </td>
    <td>
    <input type="text" name="email" />
    </td>
</tr>
<tr>
    <td>
    Bericht:
    </td>
    <td>
    <textarea name="bericht"></textarea>
    </td>
</tr>
</table>
<input type="submit" value="Verzend Anoniem Bericht" />
</form>
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #007700]}[/COLOR]
?>
- Skytop
0
Berichten
3.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Wow nice gemaakt, ik zal hem later nog wel eens gebruiken.

BTW, Welke TuT heb jij gevolg want ik wil ook PHP leren maar lukt niet.
0
Berichten
3.037
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt smile.
0
Berichten
3.978
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
bedankt biggrinen
doe zo verder thumbsup
0
Berichten
20.364
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ziet er leuk uit, maar zelf ben ik niet een voorstander van die scriptwijze die jij doet.smile
0
Berichten
832
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Bedankt, ik kan hier veel van leren.
0
Skytop

Lid · Topicstarter

Berichten
1.101
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Shahiem schreef:
Ziet er leuk uit, maar zelf ben ik niet een voorstander van die scriptwijze die jij doet.smile
Ieder zijn wijze toch santabaard
@AlleBedankjes
Bedankt biggrin
0

Jouw reactie

Deel je idee, stel een vraag of help een ander verder.

Editor laden…

Praat mee met de One2xs-community.

Inloggen om te reageren