Jeg ved ikke helt hvad du vil frem til, men prøv at kig lidt i min kode:
- <?php
- session_start();
- if(isset($_POST['submit'])){
- include("connect.php");
-
- function create($username, $usernameen)
- {
- $tid = date("d/m-Y H:i");
-
- $sql = "INSERT INTO log (username, datentime, remoteaddr) VALUES ('". $username ."', '". $time ."', 'xxx')";
- $query = mysql_query($sql) or die(mysql_error());
-
- $db_sql = "SELECT * FROM coworkers WHERE username = '". $usernameen ."'";
- $db_query = mysql_query($db_sql) or die(mysql_error());
-
- $db_row = mysql_fetch_assoc($db_query);
- if(base64_encode($username == $db_row['username']) && base64_encode($_POST['password']) == $db_row['password'])
- {
- $_SESSION['loggetind'] = "yes";
- $_SESSION['firstname'] = base64_decode($db_row['firstname']);
- $_SESSION['username'] = base64_decode($db_row['username']);
- $_SESSION['rank'] = base64_decode($db_row['rank']);
- $_SESSION['rights'] = $db_row['rights'];
-
- $newSql = "UPDATE coworkers SET lastentry = '". $tid ."' WHERE username = '". $_SESSION["username"] ."'";
- $newQuery = mysql_query($newSql);
- if(!$newQuery)
- {
- die(mysql_error());
- }
- return "JEPS";
- }
- else
- {
- return "NEJ";
- }
- }
- $base64 = base64_encode($_POST["username"]);
- echo create($_POST["username"], $base64);
- }
- ?>