inlog script
Dit is het 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
28
29
30
31
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
<form action="<? echo $_SERVER['PHP_SELF']; ?>" method="post">
<p class="Account">
Username: <br />
<input type="text" name="username"><br />
Password: <br />
<input type="password" name="password"><br />
<input type="submit" Value="Login">
</form>
<?
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$accountdata = mysql_query("SELECT * FROM users WHERE username='".$SESSION['username']."'");
$account = mysql_fetch_array($accountdata);
if (!empty($_SESSION['username']) && !empty($_SESSION['password'])){
if ($_SESSION['username'] == $account['username']){
if (md5($_SESSION['password']) == $account['password']){
$username = $_SESSION['username'];
$password = md5($_SESSION['password']);
echo "Welcome".$username;
} } }
if (isset($username) && isset($password)){
echo "Welcome".$username;
}
[/code]
[quote]
Topic verplaatst naar php.
SanThe.
[/quote]
<p class="Account">
Username: <br />
<input type="text" name="username"><br />
Password: <br />
<input type="password" name="password"><br />
<input type="submit" Value="Login">
</form>
<?
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$accountdata = mysql_query("SELECT * FROM users WHERE username='".$SESSION['username']."'");
$account = mysql_fetch_array($accountdata);
if (!empty($_SESSION['username']) && !empty($_SESSION['password'])){
if ($_SESSION['username'] == $account['username']){
if (md5($_SESSION['password']) == $account['password']){
$username = $_SESSION['username'];
$password = md5($_SESSION['password']);
echo "Welcome".$username;
} } }
if (isset($username) && isset($password)){
echo "Welcome".$username;
}
[/code]
[quote]
Topic verplaatst naar php.
SanThe.
[/quote]
Gewijzigd op 01/01/1970 01:00:00 door Bilel
Waar komt $username vandaan>
Die is nog niet gedefineerd...
En gebruik
Gewijzigd op 01/01/1970 01:00:00 door - Ariën -
Code (php)
1
2
3
4
2
3
4
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$accountdata = mysql_query("SELECT * FROM users WHERE username='".$username."'");
$account = mysql_fetch_array($accountdata);
$_SESSION['password'] = $_POST['password'];
$accountdata = mysql_query("SELECT * FROM users WHERE username='".$username."'");
$account = mysql_fetch_array($accountdata);
maar het script werkt nog steeds niet. Bedankt voor bug 1 in ieder geval
Nieuwe 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
<?php
echo "<p class=\"Account\">";
if (!empty($_POST['username']) && !empty($_POST['password'])){
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$accountdata = mysql_query("SELECT * FROM users WHERE username='".$_SESSION['username']."'");
$account = mysql_fetch_array($accountdata);
if (!empty($_SESSION['username']) && !empty($_SESSION['password'])){
if ($_SESSION['username'] == $account['username']){
if (md5($_SESSION['password']) == $account['password']){
$username = $_SESSION['username'];
$password = md5($_SESSION['password']);
echo "<p class=\"Account\">
Welcome ".$username;
} } } }
else {
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
<p class=\"Account\">
Username: <br />
<input type=\"text\" name=\"username\"><br />
Password: <br />
<input type=\"password\" name=\"password\"><br />
<input type=\"submit\" Value=\"Login\">
</form>";
}
echo "</p>";
?>
echo "<p class=\"Account\">";
if (!empty($_POST['username']) && !empty($_POST['password'])){
$_SESSION['username'] = $_POST['username'];
$_SESSION['password'] = $_POST['password'];
$accountdata = mysql_query("SELECT * FROM users WHERE username='".$_SESSION['username']."'");
$account = mysql_fetch_array($accountdata);
if (!empty($_SESSION['username']) && !empty($_SESSION['password'])){
if ($_SESSION['username'] == $account['username']){
if (md5($_SESSION['password']) == $account['password']){
$username = $_SESSION['username'];
$password = md5($_SESSION['password']);
echo "<p class=\"Account\">
Welcome ".$username;
} } } }
else {
echo "<form action=\"".$_SERVER['PHP_SELF']."\" method=\"post\">
<p class=\"Account\">
Username: <br />
<input type=\"text\" name=\"username\"><br />
Password: <br />
<input type=\"password\" name=\"password\"><br />
<input type=\"submit\" Value=\"Login\">
</form>";
}
echo "</p>";
?>
Gelieve Niet Bumpen::
Gewijzigd op 01/01/1970 01:00:00 door bilel
En de bug???
zet je wachtwoord nooit in een open sessie! of zorg ervoor dat hij md5 geëncrypteerd is
ja de DB maakt ook gebruik van een encryptie en aangezien $_SESSION maar 1 refresh meetelt heb ik een nieuw script gemaakt met cookies.