Er der ikke nogen der kan lave opretbruger-filen for dette brugersystem?
<form action=\\"tjeckfilen.php\\" method=\\"post\\">
<table width=\\"95%\\" class=\\"right_menu\\">
<tr>
<td width=\\"120\\" valign=\\"top\\">
<font size=\\"1\\" face=\\"Verdana\\">Brugernavn:</font><br>
<input name=\\"username\\" type=\\"text\\" size=\\"12\\"><br>
<font size=\\"1\\" face=\\"Verdana\\">Password:</font><br>
<input name=\\"password\\" type=\\"password\\" size=\\"12\\">
<br>
<input type=\\"submit\\" value=\\"Login\\">
</td>
<td valign=\\"top\\">
</td>
</td>
</table>
</form>
Tjeckfilen
##########################################
<?php
session_start();
if ($_POST['username'] == "" AND $_POST['password'] == "") {
$_SESSION['status'] = "nobrugerpass";
print("<script language='javascript'>location.href=index.php';</script>");
}
elseif ($_POST[username] == "") {
$_SESSION['status'] = "nobruger";
print("<script language='javascript'>location.href='index.php';</script>");
}
elseif ($_POST['password'] == "") {
$_SESSION['status'] = "nopass";
print("<script language='javascript'>location.href='index.php';</script>");
}
else {
include("mysql.php");
$password_k = $_POST[password];
$query = "SELECT id, username, password, status FROM joke_use WHERE username = '".$_POST['username']."' AND password= '".$password_k."'";
$result = mysql_query($query)or die("MySQL fejl: " . mysql_error());
$log = mysql_fetch_array($result);
if ($_POST['uasername'] = $log['username'] && $password_k = $log['password']) {
$_SESSION['status'] = "login";
$_SESSION['id'] = $log['id'];
$_SESSION['brugerstatus'] = $log['status'];
$_SESSION['user'] = $log['username'];
$low = strtolower($log['username']);
print("<script language='javascript'>location.href='user_login_ok.php';</script>");
}
else {
$_SESSION['status'] = "fejl";
print("<script language='javascript'>location.href='index.php';</script>");
}
}
?>
mysql filen
##########################################
<?php
//Connecter til MySQL databasen
$conn = mysql_connect("database server", "user", "pass");
mysql_select_db("databasenavn");
?>
MySQL
##########################################
id - int | auto | primay
username - text
password - text
status - text
Husk at ret mysqlen filen til og oprette myqsl
eller er det bare at gå til den har selv status sådan du kan ud lukke nogen menus og sider fra små bruger som ikke skal ha adgang til det
denne her fstykke code skal du smide i toppen af alle de filere du vil ha gjort sikker for ikke logget ind bruger at kommet ind
<?
session_start();
if ($_SESSION['status'] != "login") {
print('<script language=\\'javascript\\'>location.href=\\'index.php\\';</script>');
}
elseif ($_SESSION['brugerstatus'] <= 50){
print('<script language=\\'javascript\\'>location.href=\\'logud.php\\';</script>');
}
?>
Cod (Søren)
- codsweb.1go.dk -
Tag et kig!!