Jeg har skrevet noget connent til mysql database her
<?php
session_start();
mysql_connect('localhost','?','??');
mysql_select_db('???');
if(isset($_POST['login'])) {
$check = mysql_query("SELECT * FROM users WHERE username = '". $_POST['username'] ."' && password = '". $_POST['password'] ."' ");
if(mysql_num_rows($check)==1) {
$true = true;
}
if($true == true) {
while($row = mysql_fetch_assoc($check)) {
$_SESSION['id'] = $row['id'];
$_SESSION['username'] = $row['username'];
$_SESSION['password'] = $row['password'];
$_SESSION['rank'] = $row['rank'];
$_SESSION['admin'] = 1;
mysql_query("UPDATE users SET ip = '". $_SERVER['REMOTE_ADDR'] ."' WHERE id = '". $row['id'] ."' ");
}
} else {
header("Location:
http://www.b2f.dk/?s=logind");
} }
if($_GET['s']=="logaf" && $_SESSION['admin']=="1") {
unset($_SESSION['admin']);
header("Location:
http://www.b2f.dk/");
}
if($_GET['s']=="logind" && $_SESSION['admin']=="1") {
header("Location:
http://www.b2f.dk./");
}
$array = array('"', "'");
$array2 = array(""", "'");
for($i = 0; $i < count($array); $i++) {
$_POST = str_replace($array[$i], $array2[$i], $_POST);
}
?>
Det havde jeg skrevet før jeg gik over til det ny
- <form action="./" method="post" class="style2">
- <p>Brugernavn:
- <input type="text" name="username" />
- Adgangskode:
- <input type="password" name="password" />
- <input type="submit" name="login" value="Log ind" />
- <br />
- </p>
- </form>
Indlæg senest redigeret d. 13.04.2011 23:48 af Bruger #16353