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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.