Thanks for your reply. At least now it'ss display the form, though only once. Problem: After pressing submit, it goes straight to index.php, (the loginpage is at index.php?page=login_page) nomatter what i type in the form-fields. I was under the impression $SERVER[PHP_SELF] did return you to the exact page you're on... but maybe that's what it's doing, as the loginpage is included into the index.php. In that case I have no clue on how to get this working. Help greatly appreciated :) new code: [code]<?php $fields = 'Brukernavn:<br />'.write_textfield(menulogin, text, user).'<br />Passord:<br />'.write_textfield(menulogin, password, pass).'<br />'.write_submit('login', 'Logg inn!'); echo(' <h1>Logg inn</h1> '); //if no post is made if(!$_POST) { echo write_form($fields, $_SERVER[PHP_SELF], 'post'); } else { //set username and password variables, escape chars, set pass as md5 checksum $username = mysql_real_escape_string($_POST['user']); $password = md5($_POST['pass']); //select users which matches submitted password and username (It'll be submitted in a form further down) $result = mysql_query(" SELECT count(id) FROM users WHERE password='".$_POST[pass]."' AND username='".$_POST[user]."' "); //if there is a match! (access granted) if (mysql_num_rows($result) > 0) { //already escaped username and md5'ed the password $_SESSION['user'] = $_POST['user']; $_SESSION['pass'] = $_POST['pass']; echo('<p>Du er nå logget inn :)</p>'); } //no match in DB, try again else { echo('<p>Beklager, feil brukernavn eller passord!</p>'); echo write_form($fields, $_SERVER[PHP_SELF], 'post'); } //end else } ?>[/code]