Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201941
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:08:21+00:00 2026-06-17T23:08:21+00:00

I’ve got a problem with my login system/logout system. So the problem is that

  • 0

I’ve got a problem with my login system/logout system.

So the problem is that I can not login. When I enter the correct username and password I get redirected to index.php when that is actually only going to happend after I have logged out. I think the error is in login_success.php with the if (!isset($_SESSION['mittbrukarnamn'])) line, (mittbrukarnamn = myusername), that will make the problem above, but when I remove the ! so the isset is not false anymore, I can login but then the logout.php does not “work”.

And I also get an error in line 19 that starts with if ($_POST['mittbrukarnamn'] && $_POST['mittpassord']) when I enter the wrong username or password in IE 9, or does not enter any username or password. But in Google Chrome I do not get that error. Can someone tell me if this is a safe system? I am going to add a code line later that makes the password convert to MD5 and an Admin user page.

Here is the check.php

    <title>Login side</title>

<?php
session_start();

// 'vert' er det same som 'host' på engelsk (ikkje så viktig).
    $vert = "localhost";
    $brukarnamn = "root";
    $passord = "";
    $db_namn = "login";
    $tbl_namn = "members";

// Tilkobling til MySQL databasen.
    mysql_connect("$vert", "$brukarnamn", "$passord") or die ("Kan dessverre ikkje koble til databasen.");
    mysql_select_db("$db_namn") or die ("Kan ikkje finna den ynkjande tabellen 'namn'.");
?>

<?php
    if ($_POST['mittbrukarnamn'] && $_POST['mittpassord']) {

      $mittbrukarnamn = $_POST['mittbrukarnamn'];
      $mittpassord = $_POST['mittpassord'];

      $sql = "SELECT * FROM $tbl_namn WHERE `brukarnamn` = '$mittbrukarnamn' AND `passord` = '$mittpassord'";
// '$res' forkorting for 'resultat'.
      $res = mysql_query($sql);

// '$tell' er skreve på norsk, og er det same som 'count' på engelsk (f.eks. og telja til 10). Slek ein ikkje     trur da er 'tell' på engelsk; (ikkje så viktig).
      $tell = mysql_num_rows($res);

      if ($tell == 1) {
        $_SESSION['mittbrukarnamn'];
        $_SESSION['mittpassord'];
        header ("location: login_success.php");
  } else {
        echo "Brukarnamnet eller passordet er feil.";
        header ("refresh: 2; index.php");
  }

  } else {
        echo "Vennligst tast inn eit brukarnamn og eit passord.";
        header ("refresh: 2; index.php");
  }
?>

And login_success.php

<title>Medlem side</title>

<?php
  session_start();
    if (!isset($_SESSION['mittbrukarnamn'])) {
        header("location: index.php");
}
?>

<html>
<body>
Du er innlogga.<br />
<a href="logout.php"> Logg ut</a>
</body>
</html>

I hope I have made clear what the problem is. Thank you for any answers 🙂

Some of this text is on norwegian.
(mittbrukarnamn = myusername)
(mittpassord = mypassword)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:08:23+00:00Added an answer on June 17, 2026 at 11:08 pm

    Its addition to Norton’s answer:
    after placing the session_start() at the very beginning of the file,

    replace $_SESSION['mittbrukarnamn']; with $_SESSION['mittbrukarnamn']=''; to set the session variable.
    What you are doing now does not set the session variable , its only getting the $_SESSION['mittbrukarnamn']

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
public static bool CheckLogin(string Username, string Password, bool AutoLogin) { bool LoginSuccessful; // Trim
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.