Inlogsysteem
// Copyright Jorik Berkepas
Ik heb een shoutbox van php aangemaakt.
Ik wil dat de naam als je post in de shoutbox verschijnt...
Maar in deze inlogsysteem verschint alleen het ID nummer..
-----shoutbox.php------
Code (php)
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
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
<?
include('config.php');
include('safe.php');
$user = $_SESSION["user_id"]
$previousclans = $_GET["previousclans"];
$location = $_GET["location"];
$msn = $_GET["msn"];
$message = $_GET["message"];
$message1 = $_GET["message1"];
$message2 = $_GET["message2"];
$message3 = $_GET["message3"];
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('l, F j, Y');
$time = date("g:i A");
print("<b>Thank You!</b><br />Your information has been added! You can see it by <a href=savedinfo.php>Clicking Here</a>");
$out = fopen("savedinfo.php", "a");
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<small><br>Date: $date, $time</small> <br><b>User ID</b>: <a href=$msn target=_blank title=$ip>$user</a><br><b>Previous Clans</b>: $previousclans<br><b>Location</b>: $location<br><b>Game Experience</b>: $message<br><b>Clan Experience</b>: $message1<br><b>Friends/Enemys in Soldat</b>: $message2<br><b>Why you chose -:TA:-</b>:
$message3<br /><br />");
fclose($out);
?>
include('config.php');
include('safe.php');
$user = $_SESSION["user_id"]
$previousclans = $_GET["previousclans"];
$location = $_GET["location"];
$msn = $_GET["msn"];
$message = $_GET["message"];
$message1 = $_GET["message1"];
$message2 = $_GET["message2"];
$message3 = $_GET["message3"];
$ip = $_SERVER['REMOTE_ADDR'];
$date = date('l, F j, Y');
$time = date("g:i A");
print("<b>Thank You!</b><br />Your information has been added! You can see it by <a href=savedinfo.php>Clicking Here</a>");
$out = fopen("savedinfo.php", "a");
if (!$out) {
print("Could not append to file");
exit;
}
fputs ($out,implode,("\n"));
fwrite($out,"<small><br>Date: $date, $time</small> <br><b>User ID</b>: <a href=$msn target=_blank title=$ip>$user</a><br><b>Previous Clans</b>: $previousclans<br><b>Location</b>: $location<br><b>Game Experience</b>: $message<br><b>Clan Experience</b>: $message1<br><b>Friends/Enemys in Soldat</b>: $message2<br><b>Why you chose -:TA:-</b>:
$message3<br /><br />");
fclose($out);
?>
-----inloggen.php------
You are logged in.
<script language="Javascript" type="text/javascript">
location.href='';
</script>
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?
}else{
if(isset($_COOKIE['user_id'])) {
// Cookie uitlezen, sessie aanmaken
$sql = "SELECT id,status,wachtwoord,actief FROM gebruikers WHERE id='".$_COOKIE['user_id']."'";
$query = mysql_query($sql);
$rij = mysql_fetch_object($query);
$id = htmlspecialchars($rij->id);
$naam = htmlspecialchars($rij->naam);
$status = htmlspecialchars($rij->status);
$dbpass = htmlspecialchars($rij->wachtwoord);
$actief = htmlspecialchars($rij->actief);
if($dbpass == $_COOKIE['user_password'] AND $actief == 1) {
$_SESSION['user_id'] = $id;
$_SESSION['user_status'] = $status;
$_SESSION['user_naam'] = $naam;
?>
}else{
if(isset($_COOKIE['user_id'])) {
// Cookie uitlezen, sessie aanmaken
$sql = "SELECT id,status,wachtwoord,actief FROM gebruikers WHERE id='".$_COOKIE['user_id']."'";
$query = mysql_query($sql);
$rij = mysql_fetch_object($query);
$id = htmlspecialchars($rij->id);
$naam = htmlspecialchars($rij->naam);
$status = htmlspecialchars($rij->status);
$dbpass = htmlspecialchars($rij->wachtwoord);
$actief = htmlspecialchars($rij->actief);
if($dbpass == $_COOKIE['user_password'] AND $actief == 1) {
$_SESSION['user_id'] = $id;
$_SESSION['user_status'] = $status;
$_SESSION['user_naam'] = $naam;
?>
Another session made, you will be guided.
<script language="Javascript" type="text/javascript">
location.href='';
</script>
Code (php)
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
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
<?
}else{
echo "You're cookie isn't the same as the cookie in the database or your account is not activated. You may have changed your password.<br />\nYour old cookies are deleted.";
setcookie("user_id", "", time() - 3600);
setcookie("user_password", "", time() - 3600);
}
}else{
if(isset($_POST['submit'])) {
// Inloggen
$sql = "SELECT id,naam,wachtwoord,status,actief FROM gebruikers WHERE naam='".$_POST['user']."'";
$query = mysql_query($sql);
$rij = mysql_fetch_object($query);
$dbpass = htmlspecialchars($rij->wachtwoord);
$userpass = md5($_POST['pass']);
$username = md5($_POST['naam']);
$userid = htmlspecialchars($rij->id);
$userstatus = htmlspecialchars($rij->status);
$useractief = htmlspecialchars($rij->actief);
if($dbpass == $userpass) {
if($useractief == 1) {
$_SESSION['user_id'] = $userid;
$_SESSION['user_status'] = $userstatus;
if($_POST['cookie'] == "do") {
setcookie("user_id", $userid, time() + 365 * 86400);
setcookie("user_password", $dbpass, time() + 365 * 86400);
}
?>
}else{
echo "You're cookie isn't the same as the cookie in the database or your account is not activated. You may have changed your password.<br />\nYour old cookies are deleted.";
setcookie("user_id", "", time() - 3600);
setcookie("user_password", "", time() - 3600);
}
}else{
if(isset($_POST['submit'])) {
// Inloggen
$sql = "SELECT id,naam,wachtwoord,status,actief FROM gebruikers WHERE naam='".$_POST['user']."'";
$query = mysql_query($sql);
$rij = mysql_fetch_object($query);
$dbpass = htmlspecialchars($rij->wachtwoord);
$userpass = md5($_POST['pass']);
$username = md5($_POST['naam']);
$userid = htmlspecialchars($rij->id);
$userstatus = htmlspecialchars($rij->status);
$useractief = htmlspecialchars($rij->actief);
if($dbpass == $userpass) {
if($useractief == 1) {
$_SESSION['user_id'] = $userid;
$_SESSION['user_status'] = $userstatus;
if($_POST['cookie'] == "do") {
setcookie("user_id", $userid, time() + 365 * 86400);
setcookie("user_password", $dbpass, time() + 365 * 86400);
}
?>
You logged in successful.<br />
You will be redirected, if nothing happens <a href="">you can click here</a>.
<script language="Javascript" type="text/javascript">
location.href='';
</script>
Code (php)
1
2
3
4
5
6
7
8
9
10
2
3
4
5
6
7
8
9
10
<?
}else{
echo "Your account is not activated. Activate it, by clicking on the activation link send to your email.<br />\n<a href=\"javascript:history.back()\">« Go Back</a>";
}
}else{
echo "The password you enterd isn't the same as the given password of the user '".$_POST['user']."'.<br />\n<a href=\"javascript:history.back()\">« Go Back</a>";
}
}else{
// Inlogform
?>
}else{
echo "Your account is not activated. Activate it, by clicking on the activation link send to your email.<br />\n<a href=\"javascript:history.back()\">« Go Back</a>";
}
}else{
echo "The password you enterd isn't the same as the given password of the user '".$_POST['user']."'.<br />\n<a href=\"javascript:history.back()\">« Go Back</a>";
}
}else{
// Inlogform
?>