3 Replies - 689 Views - Last Post: 28 June 2011 - 08:29 AM Rate Topic: -----

#1 Taibah  Icon User is offline

  • New D.I.C Head

Reputation: -25
  • View blog
  • Posts: 41
  • Joined: 23-February 11

Undefined index still getting error!

Posted 28 June 2011 - 05:48 AM

Hi all this is very important project.

This is my code i get a error of undefined index i searched at google but no good result i tried also with sessions but still not working can somebody help me out!
<?php ob_start(); ?>
<HTML>
<HEAD>
	<TITLE>Relaunch</TITLE>
	<script Type="text/javascript" Src="relaunch.js"></SCRIPT>
	<link rel="stylesheet" type="text/css" href="relaunch.css"/>
</HEAD>
<BODY>
<DIV id="logo" >
<IMG Src="Logo.png" Style="behavior: url('Png.htc')" Border="0" Height="100" Width="759">
</DIV>
<DIV Id="Navigation">
	<IMG Usemap="#HeadMap" Id="HeadNav" Src="Nav_Compleet_Out.gif" Height="35" Width="759" Alt="" Border="0">
</DIV>
<MAP Name="HeadMap" Id="HeadMap" onmouseout="navout('HeadNav',0)">
	<AREA Shape="poly" Coords="0,0,170,0,149,34,0,34" Href="Home.php" onmouseover="navover('HeadNav',1)" onfocus="this.blur()" alt="Home">
	<AREA Shape="poly" Coords="322,0,301,34,149,34,170,0" Href="Agenda.php" onmouseover="navover('HeadNav',2)" onfocus="this.blur()" alt="Agenda">
	<AREA Shape="poly" Coords="459,0,438,34,301,34,322,0" Href="Tickets.php" onmouseover="navover('HeadNav',3)" onfocus="this.blur()" alt="Tickets">
	<AREA Shape="poly" Coords="591,0,570,34,438,34,459,0" Href="Route.php" onmouseover="navover('HeadNav',4)" onfocus="this.blur()" alt="Route">
	<AREA Shape="poly" Coords="758,0,737,34,570,34,591,0" Href="Colofon.php" onmouseover="navover('HeadNav',5)" onfocus="this.blur()" alt="Colofon">
</MAP>

<DIV Id ="LoginStatusBar">
	<IMG Style="position: absolute; left: 716px" Src="Corner.gif" Border="0">
</DIV>

<DIV Id="Content">
<?php
$Username = $_POST["Username"];
$Password = $_POST["Password"];
mysql_connect("localhost", "root", "");
mysql_select_db("Relaunch");
$Query = mysql_query("SELECT * FROM Users WHERE Username = '$Username' AND Password = '$Password'");
$Results = mysql_num_rows($Query);
if ($Results == "1") 
{
	$_SESSION["klant"] = "$Username";
	echo "u bent ingelogd";
	header("Refresh: 0; URL=inHome.php?messagex=U bent ingelogd");
}else {
	echo "u bent NIET ingelogd";
	header("Refresh: 0; URL=Home.php?messagex=Gebruikersnaam/wachtwoord onbekend. Probeer nogmaals.");
}



?>
</DIV>

<DIV Id="Footer" Style="background: #9bbe7d; width: 694px; height: 35px"
	><IMG Style="position: absolute; left: 694px" Src="Corner.gif" Border="0"
></DIV>
<?php ob_end_flush(); ?>
</BODY>
</HTML>



inhome.php
<?php ob_start(); ?>
<HTML>
<HEAD>
<TITLE>Relaunch</TITLE>
<script Type="text/javascript" Src="relaunch.js"></SCRIPT>
<link rel="stylesheet" type="text/css" href="relaunch.css"/>
</HEAD>

<BODY>

<DIV Id ="Logo"><IMG Src="Logo.png" Style="behavior: url('Png.htc')" Border="0" Height="100" Width="759"></DIV>

<DIV Id="Navigation">
<IMG Usemap="#HeadMap" Id="HeadNav" Src="Nav_Compleet_Out.gif" Height="35" Width="759" Alt="" Border="0"></DIV>
<MAP Name="HeadMap" Id="HeadMap" onmouseout="navout('HeadNav',0)">
	<AREA Shape="poly" Coords="0,0,170,0,149,34,0,34" Href="Home.php" onmouseover="navover('HeadNav',1)" onfocus="this.blur()" alt="Home">
	<AREA Shape="poly" Coords="322,0,301,34,149,34,170,0" Href="Agenda.php" onmouseover="navover('HeadNav',2)" onfocus="this.blur()" alt="Agenda">
	<AREA Shape="poly" Coords="459,0,438,34,301,34,322,0" Href="Tickets.php" onmouseover="navover('HeadNav',3)" onfocus="this.blur()" alt="Tickets">
	<AREA Shape="poly" Coords="591,0,570,34,438,34,459,0" Href="Route.php" onmouseover="navover('HeadNav',4)" onfocus="this.blur()" alt="Route">
	<AREA Shape="poly" Coords="758,0,737,34,570,34,591,0" Href="Colofon.php" onmouseover="navover('HeadNav',5)" onfocus="this.blur()" alt="Colofon">
</MAP>

<DIV Id ="LoginStatusBar"><IMG Style="position: absolute; left: 716px" Src="Corner.gif" Border="0"></DIV>
<DIV Id="LoginStatus" Style="position: absolute; top: 150px; left: 148px; width: 550px">
<?php
@session_start();
	$Username = $_SESSION['klant'];
	echo '<FONT Face="Microsoft Sans Serif" Color="white" Size="2"><B>Welkom ' . $Username . '. (<A Id="LoginStatusBarLink" Href="Logout.php">Uitloggen</A>, <A Id="LoginStatusBarLink" Href="Profiel.php">Profiel</A>, <A Id="LoginStatusBarLink" Href="showbestelling.php">Bestellingen</A>)</B></FONT>' . "\n";
?>
</DIV>


<DIV Id="Content">
	<DIV id="Messages">

		<?php
		if(isset($_GET['messagex']))
		{
			echo $_GET['messagex'];
		}
		?>
	</DIV>
	<DIV Id="Inleiding">
		Amsterdam ArenA<BR>
		Muziek en showspektakel met internationale allure.<BR>
		Shakira, Jennifer Lopez en Kylie Minogue.<BR>
		Relaunch:<BR>
		Een sensatie om niet te missen!<BR><BR>
		Bestel Uw tickets nu!
		
	</DIV>
	<DIV Id="Agenda">
		<OBJECT Type="application/x-shockwave-flash" Data="Agenda.swf?xmlfile=Agenda.xml" Name="Agenda" Width="294" Height="178">
			<PARAM Name="movie" Value="Agenda.swf?xmlfile=Agenda.xml">
			<PARAM Name="wmode" Value="transparent">
			<PARAM Name="quality" Value="high">
		</OBJECT>
	</DIV>
	
</DIV>


<DIV Id="Footer">
	<IMG Style="position: absolute; left: 694px" Src="Corner.gif" Border="0">
</DIV>
<?php ob_end_flush(); ?>
</BODY>
</HTML>





Undefined index: klant in C:\Program Files (x86)\EasyPHP-5.3.5.0\www\Relaunch\inHome.php on line 27

Is This A Good Question/Topic? 0
  • +

Replies To: Undefined index still getting error!

#2 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 947
  • View blog
  • Posts: 2,355
  • Joined: 15-February 11

Re: Undefined index still getting error!

Posted 28 June 2011 - 06:02 AM

$_SESSION['klant'] was never initialized yet you're trying to retrieve a value from it. This is due to the fact that you never started the session in your first script.
Was This Post Helpful? 1
  • +
  • -

#3 Taibah  Icon User is offline

  • New D.I.C Head

Reputation: -25
  • View blog
  • Posts: 41
  • Joined: 23-February 11

Re: Undefined index still getting error!

Posted 28 June 2011 - 07:25 AM

Thank you that problem is now solved now i got exactly the same problem but in a diffrent sutiation look the code i tried to put in a issset but its gave me undefined errors. Or can it be easyphp is there any trick to remove the notice from easyphp

	<DIV Id="Inleiding">
		<form method="post" action="<?php echo $_SERVER["PHP_SELF"]?>">
			Artiest naam<input type="text" name="artiest"></br>
			Datum<input type="text" name="datum"></br>
			prijs<input type="text" name="prijs"></br>
			<input type="submit" name="verzenden" value="Voeg concert toe"></br>
		</form>
		
		<?php 
		if(!isset($_POST["submit"]))
		
		{
			$con = mysql_connect("localhost", "root", "");
			if (!$con)
			{
				die('Could not connect: ' . mysql_error());
			}
			mysql_select_db("Relaunch");
			$sql="INSERT INTO concerten (artiest, concertdatum, prijs)VALUES('$_POST[artiest]','$_POST[datum]','$_POST[prijs]')";
			if (!mysql_query($sql,$con))
			{
			  echo "fout op gedteren";
			}
			else{
				echo "conserten succesvol toegevoegd";
			}

			mysql_close($con);
		}
		?>


This post has been edited by Taibah: 28 June 2011 - 07:40 AM

Was This Post Helpful? 0
  • +
  • -

#4 codeprada  Icon User is offline

  • Changed Man With Different Priorities
  • member icon

Reputation: 947
  • View blog
  • Posts: 2,355
  • Joined: 15-February 11

Re: Undefined index still getting error!

Posted 28 June 2011 - 08:29 AM

You've got if(!isset($_POST["submit"])) which means that if your submit button wasn't clicked then you'll process the form.
It should be the other way around.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1