Het lukt mij niet om een cookie te setten
onder aan de topic full code.
Ik heb geprobeert om te checken met isset maar toch krijg ik een error. En zelf als ik alle cookies weg haal krijg ik een error en gaat hij niet verder.
error @ php script
en dan nu de php script worstel er al een halve dag mee vannaf 4 uur.. hele script al een paar keer omgegooit.
onder aan de topic full code.
Ik heb geprobeert om te checken met isset maar toch krijg ik een error. En zelf als ik alle cookies weg haal krijg ik een error en gaat hij niet verder.
error @ php script
code:
1
2
3
4
5
| Your inside the system Warning: Cannot add header information - headers already sent by (output started at C:\apache\htdocs\project\index.php:56) in C:\apache\htdocs\project\index.php on line 10 Warning: Cannot add header information - headers already sent by (output started at C:\apache\htdocs\project\index.php:56) in C:\apache\htdocs\project\index.php on line 13 and yess... ik hate you.. |
en dan nu de php script worstel er al een halve dag mee vannaf 4 uur.. hele script al een paar keer omgegooit.
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
| <? // check if its works.. echo $HTTP_COOKIE_VARS["username_c"]; echo $HTTP_COOKIE_VARS["password_c"]; // Autenticate User and if true dont display nesasary objects if(AuthenticationUser($username, $password)) { if (!isset($username_c)) { setcookie ("username_c", $username); } if (!isset($password_c)) { setcookie ("password_c", $password); } $loginview = "0"; echo " and yess... ik hate you.. "; } elseif(AuthenticationUser($HTTP_COOKIE_VARS["username_c"], $HTTP_COOKIE_VARS["password_c"])) { $loginview = "0"; echo " and yess... ik hate you.. WITH COOKIES"; } elseif($username &amp;amp;&amp;amp; $password) { echo "$username : $password"; echo "error"; $loginview = "0"; $login_error = "Bad user/password combination"; echo print_login($login_error); } else { $loginview = "1"; echo "nothing"; } if ($loginview) { echo print_login($login_error); } // temp $lifetime = time() + 3600; $db = "Devnet"; function AuthenticationUser($username, $password) { // Open a persistant connection with the MySQL server if (!($link = mysql_pconnect("localhost"))) { DisplayErrorMessage(sprintf("Internal <b>SQL</B> error: %d %s", mysql_errno(), mysql_error())); return 0 ; } // Search 4 username in database / no input check (dangerous) if (!($result = mysql_db_query(Devnet, "SELECT * FROM user_profile WHERE Username='$username'"))) { DisplayErrorMessage(sprintf("Internal <b>SQL</B> error bij inlog check: %d %s", mysql_errno(), mysql_error())); return 0 ; } if (($row = mysql_fetch_array($result)) &amp;amp;&amp;amp; ($password == $row["Password"] &amp;amp;&amp;amp; $password != " ")) { echo "Your inside the system"; return 1 ; } else { return 0 ; } } function DisplayErrorMessage($mssg) { echo "<BLOCKQUOTE><BLOCKQUOTE><BLOCKQUOTE><B>$mssg</B></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE>"; } function print_login($login_error) { echo " <HTML><HEAD><TITLE>User Login</TITLE></HEAD><BODY><FORM METHOD=POST><INPUT TYPE=\"text\" NAME=\"username\">"; printf("<INPUT TYPE=\"text\" NAME=\"password\" VALUE=\"%s\">", $login_error); echo "<INPUT TYPE=\"submit\"></FORM></BODY></HTML>"; } ?> |