Ingelogd blijven

Gestart doorNielsba1 reacties41 weergaven

2 berichten · pagina 1 van 1

Nielsba

Lid · Topicstarter

Berichten
1.296
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Mensen ik zou graag wat willen .Ik heb een beetje verstand van PHP maar ik zoek voor mijn login.php een ingelogd blijven script via cookies of sessions maakt niet uit.

De Login.php :
Spoiler tonen
<h1>Inloggen</h1>
[COLOR= #0000BB]<?php[/COLOR]

[URL="http://www.php.net/if"]if[/URL] [COLOR= #007700]([/COLOR][COLOR= #0000BB]$paswoord_db[/COLOR] [COLOR= #007700]===[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$password[/COLOR][COLOR= #007700])) {[/COLOR] 
[URL="http://www.php.net/session_start"]session_start[/URL][COLOR= #007700]();[/COLOR] 
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$username[/COLOR][COLOR= #007700];[/COLOR] 
[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$password[/COLOR][COLOR= #007700];[/COLOR] 
[URL="http://www.php.net/session_write_close"]session_write_close[/URL][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]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])[/COLOR]
[URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"username"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]] ,[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]() +[/COLOR] [COLOR= #0000BB]2419200[/COLOR][COLOR= #007700]);[/COLOR] 
[URL="http://www.php.net/setcookie"]setcookie[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"password"[/COLOR][COLOR= #007700],[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]] ,[/COLOR] [URL="http://www.php.net/time"]time[/URL][COLOR= #007700]() +[/COLOR] [COLOR= #0000BB]2419200[/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]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]])){[/COLOR]
?>
<div id="error">Je bent al ingelogd!</div><br />
[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #007700]}[/COLOR][URL="http://www.php.net/else"]else[/URL][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]submit[/COLOR][COLOR= #007700]])){[/COLOR]

[COLOR= #0000BB]$uQuery[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"SELECT * 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]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]username[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]" AND password = "[/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/md5"]md5[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$_POST[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]password[/COLOR][COLOR= #007700]]) .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]
[COLOR= #0000BB]$uFetch[/COLOR] [COLOR= #007700]=[/COLOR] [URL="http://www.php.net/mysql_fetch_assoc"]mysql_fetch_assoc[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uQuery[/COLOR][COLOR= #007700]);[/COLOR]

[URL="http://www.php.net/if"]if[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]type[/COLOR][COLOR= #007700]] ==[/COLOR] [COLOR= #0000BB]4[/COLOR][COLOR= #007700]){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="error">Je bent verwijderd van site-city.</div>[/COLOR][COLOR= #007700];

}[/COLOR][URL="http://www.php.net/elseif"]elseif[/URL][COLOR= #007700]([/COLOR][COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]banned_until[/COLOR][COLOR= #007700]] !=[/COLOR] [COLOR= #DD0000]0000-00-00 00:00:00[/COLOR] and [COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]banned_until[/COLOR][COLOR= #007700]] >=[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Y-m-d H:i:s[/COLOR][COLOR= #007700])){[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]Server tijd: [/COLOR] [COLOR= #007700].[/COLOR] [URL="http://www.php.net/date"]date[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]Y-m-d H:i:s[/COLOR][COLOR= #007700]) .[/COLOR] [COLOR= #DD0000]<br />[/COLOR][COLOR= #007700];[/COLOR]

[URL="http://www.php.net/echo"]echo[/URL] [COLOR= #DD0000]<div id="error">Je bent verbannen tot [/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]banned_until[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000].<br />Reden: [/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]ban_reason[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]</div>[/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]$uQuery[/COLOR][COLOR= #007700]) >[/COLOR] [COLOR= #0000BB]0[/COLOR][COLOR= #007700]){[/COLOR]

[COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] =[/COLOR] [COLOR= #0000BB]$uFetch[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]];[/COLOR]

[URL="http://www.php.net/mysql_query"]mysql_query[/URL][COLOR= #007700]([/COLOR][COLOR= #DD0000]"UPDATE users SET visits = visits+1, ip = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SERVER[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]REMOTE_ADDR[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]" WHERE id = "[/COLOR] [COLOR= #007700].[/COLOR] [COLOR= #0000BB]$_SESSION[/COLOR][COLOR= #007700][[/COLOR][COLOR= #DD0000]id[/COLOR][COLOR= #007700]] .[/COLOR] [COLOR= #DD0000]""[/COLOR][COLOR= #007700])[/COLOR] or [URL="http://www.php.net/die"]die[/URL][COLOR= #007700]([/COLOR][URL="http://www.php.net/mysql_error"]mysql_error[/URL][COLOR= #007700]());[/COLOR]

?>
<div id="succes">Je bent succesvol ingelogd, je word doorgestuurd naar de homepagina..</div>
<meta http-equiv="refresh" content="0;url=index.php">
function WriteCookie (cookieName, cookieValue, expiry) 
{
    var expDate = new Date();

    expDate.setTime (expDate.getTime() + expiry);
    document.cookie = cookieName + "=" + escape (cookieValue) + "; expires=" + expDate.toGMTString() + "; path=/";
}

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

[COLOR= #007700]}[/COLOR][URL="http://www.php.net/else"]else[/URL][COLOR= #007700]{[/COLOR]
?>
<div id="error">Je hebt de verkeerde gegevens ingevuld</div><br />
[COLOR= #0000BB]<?php[/COLOR]

[COLOR= #007700]}

}[/COLOR]

?>

<form method="post" action="?p=login" id="bigForm">

<table style="border: 0; width: 100%; padding: 4px;">
<tr>
<td style="width: 20%;">Gebruikersnaam:</td>
<td><input type="text" name="username" /></td>
</tr>

<tr>
<td style="width: 20%;">Wachtwoord:</td>
<td><input type="password" name="password" /></td>
</tr>


<tr>
<td style="width: 20%;"></td>
<td><input type="submit" name="submit" value="Inloggen" /></td>
</tr>

</table>

</form>

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

[COLOR= #007700]}[/COLOR]

?>
En graag ik hoop dat iemand een reactie neer zet met de code maar dan aangepast met de ingelogd blijven script biggrin heel erg bedankt hier zoek ik echt naar !
0
Berichten
3.788
Reputatie
0
Punten
0,00
Lid sinds
Laatst gezien
Ik heb hier een X een tut voor geschreven, zal hem zo posten!

EDIT:
http://www.one2xs.com/threads/31703
Gewoon wat dingen aanpassen en je kan hem inbouwen
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