PHP Code:
<?
session_start();
include "data.php";
$conn = mysql_connect("$server", "$user", "$pwd");
$get = mysql_db_query($dbname, "SELECT * from users where anvendarnamn = '".$_POST['anvendarnamn']."' and losenord = '".$_POST['losenord']."'") or exit(mysql_error());
$num = mysql_num_rows($get);
if($num != 0) {
while ($r = mysql_fetch_array($get)) {
setcookie('anvendarnamn',$r["anvendarnamn"],time()+86400);
setcookie('online',$r["true"],time()+86400);
setcookie('uid',$r["id"],time()+86400);
Header("Location: index.php");
}
exit;
} else {
Header("Location: index.php?error=true");
exit;
}
?>PHP Code:
<?
if (isset($_COOKIE['online']) AND 'true' == $_COOKIE['online']){
echo $_COOKIE['anvendarnamn']; ?><br>
<a href="?do=profil">Profil</a><br>
<a href="logout.php">Logga ut</a> <br>
<? } else { ?>
<?
if ($_GET['error'] == "true") {
echo "<um>Fel lösenord eller användarnamn</um>";
}
?>
Formulär
<? } >men när man skriver in rätt, då blir de inge bra.
Comment