Hey,
Ik heb nu een andere geprobeerd, alleen die werkt ook niet, Ik zal hem wel even laten zien, ik heb de regsiter.php, login.php en index.php in de map "login" gezet, en in de map login heb ik "includes" gezet, alleen hij werkt niet
config.php;functions.php;En tenslotte, index.php (er zijn er meer, alleen deze glitcht)Live demo: http://minecraftclub.eu/login/index.php (denk ik, ik ga er heen via de DirectAdmin...)
Alvast bedankt!
Bram
Ik heb nu een andere geprobeerd, alleen die werkt ook niet, Ik zal hem wel even laten zien, ik heb de regsiter.php, login.php en index.php in de map "login" gezet, en in de map login heb ik "includes" gezet, alleen hij werkt niet

config.php;
Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]// start the session before any output. [/COLOR]
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR]
[COLOR= #FF8000]// Set the folder for our includes [/COLOR]
[COLOR= #0000BB]$sFolder[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]login[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]/***************
Database Connection
You will need to change the user (user)
and password (password) to what your database information uses.
Same with the database name if you used something else.
****************/[/COLOR]
[URL="http://www.php.net/mysql_connect"]mysql_connect[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]159.253.5.5[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]minecaft_brem[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]wachtwoord[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Unable to connect to the database: "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/mysql_select_db"]mysql_select_db[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]minecaft_login[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Unable to switch to the database: "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #FF8000]/***************
password salts are used to ensure a secure password
hash and make your passwords much harder to be broken into
Change these to be whatever you want, just try and limit them to
10-20 characters each to avoid collisions.
****************/[/COLOR]
[URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]SALT1[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]24859f@#$#@$[/COLOR][COLOR= #007700]);[/COLOR]
[URL="http://www.php.net/define"]define[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]SALT2[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #DD0000]^&@#_-=+Afda$#%[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// require the function file [/COLOR]
[URL="http://www.php.net/require_once"]require_once[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]DOCUMENT_ROOT[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #0000BB]$sFolder[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]/includes/functions.php[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// default the error variable to empty. [/COLOR]
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]error[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// declare $sOutput so we do not have to do this on each page. [/COLOR]
[COLOR= #0000BB]$sOutput[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]""[/COLOR][COLOR= #007700];[/COLOR]
?>Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[COLOR= #FF8000]/***********
bool createAccount (string $pUsername, string $pPassword)
Attempt to create an account for the passed in
username and password.
************/[/COLOR]
[COLOR= #007700]function[/COLOR] createAccount[COLOR= #007700]([/COLOR][COLOR= #0000BB]$pUsername[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$pPassword[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #FF8000]// First check we have data passed in. [/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]$pUsername[/COLOR][COLOR= #007700]) && ![/COLOR][URL="http://www.php.net/empty"]empty[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pPassword[/COLOR][COLOR= #007700])) {[/COLOR]
[COLOR= #0000BB]$uLen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pUsername[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$pLen[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/strlen"]strlen[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pPassword[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #FF8000]// escape the $pUsername to avoid SQL Injections [/COLOR]
[COLOR= #0000BB]$eUsername[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pUsername[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT username FROM users WHERE username = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$eUsername[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/COLOR][COLOR= #007700];[/COLOR]
[COLOR= #FF8000]// Note the use of trigger_error instead of or die. [/COLOR]
[COLOR= #0000BB]$query[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$sql[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Query Failed: "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #FF8000]// Error checks (Should be explained with the error) [/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$uLen[/COLOR] [COLOR= #007700]<=[/COLOR] [COLOR= #0000BB]4[/COLOR] [COLOR= #007700]||[/COLOR] [COLOR= #0000BB]$uLen[/COLOR] [COLOR= #007700]>=[/COLOR] [COLOR= #0000BB]11[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]error[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]"Username must be between 4 and 11 characters."[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$pLen[/COLOR] [COLOR= #007700]<[/COLOR] [COLOR= #0000BB]6[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]error[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]"Password must be longer then 6 characters."[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL] [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] [COLOR= #0000BB]1[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]error[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #DD0000]"Username already exists."[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #FF8000]// All errors passed lets
// Create our insert SQL by hashing the password and using the escaped Username. [/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"INSERT INTO users (`username`, `password`) VALUES ("[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$eUsername[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #DD0000]", "[/COLOR] [COLOR= #007700].[/COLOR] hashPassword[COLOR= #007700]([/COLOR][COLOR= #0000BB]$pPassword[/COLOR][COLOR= #007700],[/COLOR] SALT1[COLOR= #007700],[/COLOR] SALT2[COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]");"[/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= #0000BB]$sql[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Query Failed: "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$query[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
}
}
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
}[/COLOR]
[COLOR= #FF8000]/***********
string hashPassword (string $pPassword, string $pSalt1, string $pSalt2)
This will create a SHA1 hash of the password
using 2 salts that the user specifies.
************/[/COLOR]
[COLOR= #007700]function[/COLOR] hashPassword[COLOR= #007700]([/COLOR][COLOR= #0000BB]$pPassword[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$pSalt1[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"2345#$%@3e"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$pSalt2[/COLOR][COLOR= #007700]=[/COLOR][COLOR= #DD0000]"taesa%#@2%^#"[/COLOR][COLOR= #007700]) {[/COLOR]
[URL="http://www.php.net/return"]return[/URL] [URL="http://www.php.net/sha1"]sha1[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pSalt2[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$pPassword[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$pSalt1[/COLOR][COLOR= #007700]));
}[/COLOR]
[COLOR= #FF8000]/***********
bool loggedIn
verifies that session data is in tack
and the user is valid for this session.
************/[/COLOR]
[COLOR= #007700]function[/COLOR] loggedIn[COLOR= #007700]() {[/COLOR]
[COLOR= #FF8000]// check both loggedin and username to verify user. [/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]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]loggedin[/COLOR][COLOR= #007700]]) &&[/COLOR] [URL="http://www.php.net/isset"]isset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]])) {[/COLOR]
[URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
}[/COLOR]
[COLOR= #FF8000]/***********
bool logoutUser
Log out a user by unsetting the session variable.
************/[/COLOR]
[COLOR= #007700]function[/COLOR] logoutUser[COLOR= #007700]() {[/COLOR]
[COLOR= #FF8000]// using unset will remove the variable
// and thus logging off the user. [/COLOR]
[URL="http://www.php.net/unset"]unset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]);[/COLOR]
[URL="http://www.php.net/unset"]unset[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]loggedin[/COLOR][COLOR= #007700]]);[/COLOR]
[URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
}[/COLOR]
[COLOR= #FF8000]/***********
bool validateUser
Attempt to verify that a username / password
combination are valid. If they are it will set
cookies and session data then return true.
If they are not valid it simply returns false.
************/[/COLOR]
[COLOR= #007700]function[/COLOR] validateUser[COLOR= #007700]([/COLOR][COLOR= #0000BB]$pUsername[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$pPassword[/COLOR][COLOR= #007700]) {[/COLOR]
[COLOR= #FF8000]// See if the username and password are valid. [/COLOR]
[COLOR= #0000BB]$sql[/COLOR] [COLOR= #007700]=[/COLOR] [COLOR= #DD0000]"SELECT username FROM users
WHERE username = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_real_escape_string"]mysql_real_escape_string[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$pUsername[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]" AND password = "[/COLOR] [COLOR= #007700].[/COLOR] hashPassword[COLOR= #007700]([/COLOR][COLOR= #0000BB]$pPassword[/COLOR][COLOR= #007700],[/COLOR] SALT1[COLOR= #007700],[/COLOR] SALT2[COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]" LIMIT 1"[/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= #0000BB]$sql[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/trigger_error"]trigger_error[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"Query Failed: "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #FF8000]// If one row was returned, the user was logged in! [/COLOR]
[URL="http://www.php.net/if"]if[/URL] [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] [COLOR= #0000BB]1[/COLOR][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]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$row[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]];[/COLOR]
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]loggedin[/COLOR][COLOR= #007700]] =[/COLOR] true[COLOR= #007700];[/COLOR]
[URL="http://www.php.net/return"]return[/URL] true[COLOR= #007700];
}[/COLOR]
[URL="http://www.php.net/return"]return[/URL] false[COLOR= #007700];
}[/COLOR]
?>Spoiler tonen
[COLOR= #0000BB]<?php[/COLOR]
[URL="http://www.php.net/require"]require[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]DOCUMENT_ROOT[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]login/config.php[/COLOR][COLOR= #007700]);[/COLOR]
[COLOR= #0000BB]$sOutput[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<div id="index-body">[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR]loggedIn[COLOR= #007700]()) {[/COLOR]
[COLOR= #0000BB]$sOutput[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<h2>Welcome!</h2>
Hello, [/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000] how are you today?<br />
<h4>Would you like to <a href="login.php?action=logout">Logout?</a></h4>[/COLOR][COLOR= #007700];
}[/COLOR][URL="http://www.php.net/else"]else[/URL] [COLOR= #007700]{[/COLOR]
[COLOR= #0000BB]$sOutput[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]<h2>Welcome to our site</h2><br />
<h4>Would you like to <a href="login.php">login</a>?</h4>
<h4>Create a new <a href="register.php">account</a>?</h4>[/COLOR][COLOR= #007700];
}[/COLOR]
[COLOR= #0000BB]$sOutput[/COLOR] [COLOR= #007700].=[/COLOR] [COLOR= #DD0000]</div>[/COLOR][COLOR= #007700];[/COLOR]
[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #0000BB]$sOutput[/COLOR][COLOR= #007700];[/COLOR]
?>Alvast bedankt!
Bram
37:

