Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
lab4_code [2009-10-06 12:05] Joakim Forsgren |
lab4_code [2016-11-30 22:38] Joakim Forsgren |
||
---|---|---|---|
Line 1: | Line 1: | ||
====== Kod till Lab4 ====== | ====== Kod till Lab4 ====== | ||
- | Ett exempel på hur man skulle kunna göra lab 4 | + | Ett exempel på hur man skulle kunna göra lab 4, viktigt att ni fattar vad ni gör. |
+ | Minst 3 olika filer, en som sköter inloggning och en som sköter utloggning och den 3:e som är själva sidan. | ||
+ | |||
+ | === Inloggning (do_login.php) === | ||
+ | <php> | ||
+ | highlight_file(' | ||
+ | </ | ||
+ | |||
+ | === Utloggning (do_logout.php) === | ||
+ | <php> | ||
+ | highlight_file(' | ||
+ | </ | ||
+ | |||
+ | <code php> | ||
+ | <?php | ||
+ | include_once ' | ||
+ | |||
+ | // Om man har prövat att logga in. | ||
+ | if (!empty($_POST[' | ||
+ | // Kollar EMail och Password, bör bara finnas en... | ||
+ | $query = " | ||
+ | $result = mysqli_query($link, | ||
+ | if (mysqli_num_rows($result) != 1) { | ||
+ | header(' | ||
+ | exit(); | ||
+ | } | ||
+ | // Nu har vi en OK inloggning! | ||
+ | // Sätter alla session variabler och går till sidan start.php. | ||
+ | $row = mysqli_fetch_assoc($result); | ||
+ | $_SESSION[' | ||
+ | $_SESSION[' | ||
+ | $_SESSION[' | ||
+ | header(' | ||
+ | exit(); | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | |||
+ | === Själva sidan (lab4.php) === | ||
<php> | <php> | ||
highlight_file(' | highlight_file(' | ||
</ | </ | ||