hi. ik heb een raar cookie probleem bij mijn login script.
ik 2 file's hier onder. account en check.php
de laatste check password met pass db. dan wordt er geredirect naar account.php
maar dan komt het probleem. ik krijg die cookie niet uit gelezen. rara waarom niet?
wie ziet de oplossing.
bedankt.
--------------------------------
file's..
check.php
account.php
ik 2 file's hier onder. account en check.php
de laatste check password met pass db. dan wordt er geredirect naar account.php
maar dan komt het probleem. ik krijg die cookie niet uit gelezen. rara waarom niet?
wie ziet de oplossing.
bedankt.
--------------------------------
file's..
check.php
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
| <? include("db_connect.php"); include("config.php"); // id, password are selected out of the db. $sql = "SELECT id, pass FROM users WHERE user='$user'"; $sql_result = mysql_query($sql) or die ("MySql wasn't able to execute this Query"); $row = mysql_fetch_array($sql_result); $id = $row[id]; $pass_db = $row[pass]; // password check. if (strlen($user) == 0 OR strlen($pass) == 0) {$pass = wrong; } if ($pass == $pass_db) { setcookie("id", $id, 0); setcookie("secret", $secret_word, 0); // redirect to account.php header("Location: ../account.php?action=main"); } else { ?> error <? } ?> |
account.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| <? // include the databse connect information and config file include("includes/db_connect.php"); include("includes/config.php"); if ($HTTP_COOKIE_VARS["secret"] == $secret_word) { $sql = "SELECT user from users where id = $id"; $sql_result = mysql_query($sql) or die ("MySql wasn't able to execute this Query"); $row = mysql_fetch_array($sql_result); $user = $row[user]; echo "<BR> Welcome to your Account $user <BR><BR>"; } else { echo "error"; } ?> |