I have a code and want to edit it. Now I try to change stuff, but I dont get why it worked before and now it doesn't anymore. First I had this:
<?php
session_start();
$mysqli = new mysqli("localhost", "root", "usbw", "accounts");
$mysqli2 = new mysqli("localhost", "root", "usbw", "forum");
$alles_goed=false;
if (isset($_POST['title'])) {
$alles_goed=true;
$description=$_POST['description'];
$title=$_POST['title'];
$username=$_SESSION['username'];
$usernamecheck = $mysqli->query("SELECT * from account_information where username ='". $username ."'");
//etc
This was my edit:
<?php
session_start();
$mysqli = new mysqli("localhost", "root", "usbw", "accounts");
$mysqli2 = new mysqli("localhost", "root", "usbw", "forum");
$alles_goed=false;
$username=$_SESSION['username'];
$usernamecheck = $mysqli->query("SELECT * from account_information where username ='". $username ."'");
if (isset($_POST['title'])) {
$alles_goed=true;
$description=$_POST['description'];
$title=$_POST['title'];
//etc
This should work fine right? Still for some reason I get this error:
Undefined index: username
at:
$username=$_SESSION['username'];
What am I doing wrong and why isn't the second one possible?
EDIT:
I want to not show my form when the SESSION doesn't exists. So I got that but I want the errors gone.