2 Replies - 5585 Views - Last Post: 30 March 2010 - 09:42 AM Rate Topic: -----

#1 mahfuzwit  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 3
  • Joined: 30-March 10

Remove Undefined index: name in E:\wamp\www\jobsite\index.php on line

Posted 30 March 2010 - 01:32 AM

hi,

I am new in php. please help me. How can i remove this error. The error is:

Undefined index: name in E:\wamp\www\jobsite\index.php on line 4

Undefined index: user in E:\wamp\www\jobsite\index.php on line 6

Undefined index: password in E:\wamp\www\jobsite\index.php on line 7

My code is
<?php
	session_start();
	include "connection.php";
	if($_SESSION['name']=='')
	{
		$uname = $_POST['user'];
		$pass = $_POST['password'];
		if(!empty($uname)){
			$sql = "SELECT * FROM login WHERE username = '$uname' AND password = '".md5($pass)."'";
			$rs = mysql_query($sql);
			if($rs && mysql_num_rows($rs) > 0)
			{
				$_SESSION['name'] = $uname;
				echo "<script> location.replace('logout.php')</script>";
			}
			else
				echo "<script> alert('Wrong Username or Password'); </script>";
		}
	}
	else
		echo "<script> location.replace('logout.php')</script>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>www.ejobs.com</title>
</head>

<body>
	<div>Login<br/><br/>
		<form action="" method="post">
			Username: <input type="text" name="user" /><br /><br />
			Password: <input type="password" name="password" /><br /><br />
			<a style="color: rgb(83, 116, 242);" class="arial10px" target="_blank" href="forget.php">Forgot password?</a>
			<input type="submit" value="Login"><br/><br/>
			<a style="color: rgb(83, 116, 242);" class="arial10px" target="_blank" href="ragistation1.php">Create New Account</a>
		</form>
	</div>

</body>
</html>


Please help me

Thanks
Mahfuz

Admin Edit: Please use code tags when posting your code. Code tags are used like so => :code:

Thanks,
PsychoCoder :)

Is This A Good Question/Topic? 0
  • +

Replies To: Remove Undefined index: name in E:\wamp\www\jobsite\index.php on line

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1639
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Remove Undefined index: name in E:\wamp\www\jobsite\index.php on line

Posted 30 March 2010 - 09:24 AM

For starters welcome to Dream.In.Code, hope you enjoy your stay with us.

This belongs in the PHP forum, this forum is for introductions only. Moved to PHP :)
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6058
  • View blog
  • Posts: 23,496
  • Joined: 23-August 08

Re: Remove Undefined index: name in E:\wamp\www\jobsite\index.php on line

Posted 30 March 2010 - 09:42 AM

If you use isset(variablename) you can get rid of those errors/notices.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1