Jump to content

SESSION problem


Bravat

Recommended Posts

I have this error, and I cann't find soluiton:

Notice: Undefined index: ime in C:\wamp\www\web\login_public.php on line 26

Notice: Undefined index: ime in C:\wamp\www\web\login_public.php on line 27

 

This is the code:

<?php require_once("public/includes/session.php"); ?>
<?php require_once("public/includes/connection.php"); ?>

<?php  

		if(!$_POST['submit']){
			header('refresh:0; url=index.php');}
		else {
		$korisnik = $_POST['korisnicko_ime']; 
		$lozinka = $_POST['lozinka'];
		$lozinka_db = sha1($lozinka);

			if ($korisnik && $lozinka){
				$query = mysql_query("SELECT * FROM korisnik WHERE korisnicko_ime = '$korisnik' ");
				$numrow = mysql_num_rows($query);

				if($numrow != 0){

					while ($row = mysql_fetch_assoc($query)){
						$korisnik_db = $row['korisnicko_ime'];
						$db_lozinka = $row['lozinka'];
						$ime = $row['ime'];
						}
					if ($korisnik == $korisnik_db && $lozinka_db == $db_lozinka){
						echo "Uspesno ste ulogovani";
						$_SESSION['ime'] == $ime;
						echo $_SESSION['ime'];
						}
					else { echo "Lozinka je netacna"; }							
					} else {die("Korisnik ne postoji");}	
			}
		}

?>

 

What seems to be the problem  :confused:

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/226823-session-problem/
Share on other sites

The same error is reported: Here is the code again ( basically changed first line and the $_SESSION lines):

<?php session_start(); ?>
<?php require_once("public/includes/connection.php"); ?>

<?php  

		if(!$_POST['submit']){
			header('refresh:0; url=index.php');}
		else {
		$korisnik = $_POST['korisnicko_ime']; 
		$lozinka = $_POST['lozinka'];
		$lozinka_db = sha1($lozinka);

			if ($korisnik && $lozinka){
				$query = mysql_query("SELECT * FROM korisnik WHERE korisnicko_ime = '$korisnik' ");
				$numrow = mysql_num_rows($query);

				if($numrow != 0){

					while ($row = mysql_fetch_assoc($query)){
						$korisnik_db = $row['korisnicko_ime'];
						$db_lozinka = $row['lozinka'];
						$ime = $row['ime'];
						}
					if ($korisnik == $korisnik_db && $lozinka_db == $db_lozinka){
						echo "Uspesno ste ulogovani";
						$_SESSION['username'] == $ime;
						echo $_SESSION['username'];
						}
					else { echo "Lozinka je netacna"; }							
					} else {die("Korisnik ne postoji");}	
			}
		}

?>

Link to comment
https://forums.phpfreaks.com/topic/226823-session-problem/#findComment-1170419
Share on other sites

See if there's a values to assign. Temporarily add the line I've pointed out in the code, and see if $row['ime'] even has a value.

 

if ($korisnik == $korisnik_db && $lozinka_db == $db_lozinka){
                     echo "Uspesno ste ulogovani";
                     echo '<br>$row[\'ime\'] = [ ' . $row['ime'] . ' ]<br>'; // <---- ADD THIS FOR DEBUGGING
                     $_SESSION['ime'] == $ime;
                     echo $_SESSION['ime'];
                     }

Link to comment
https://forums.phpfreaks.com/topic/226823-session-problem/#findComment-1170421
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.