Notice: Undefined index: name in C:\xampp\htdocs\temps

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Notice: Undefined index: name in C:\xampp\htdocs\temps

Postby Hamish » 19. March 2012 12:48

I am writing a mysql query with a form in php; all the 'include' files and connections are working (I have checked and confirmed this) and I have a connection with phpMyAdmin . When I pass the .php file to localhost I get the following response for each variable:

Notice: Undefined index: name in C:\xampp\htdocs\

The code I am using is :

$name=$_POST['name'];
$user=$_POST['email'];
$maintel=$_POST['maintel'];
$mobtel=$_POST['name'];
$organisation=$_POST['organisation'];
$group_leader=$_POST['group_leader'];
$supervisor=$_POST['supervisor'];
$volunteer=$_POST['volunteer'];
$assessor=$_POST['assessor'];

$query = "INSERT INTO names (name, user, maintel, mobtel, organisation, group_leader, supervisor, volunteer, assessor)
VALUES('$name','$user', '$maintel', '$mobtel', '$organisation', '$group_leader', '$supervisor', '$volunteer', '$assessor' )";
$result = mysql_query($query) or die(mysql_error());
return $result;

mysql_close();


echo <<<_END
<form method='post' action='member.php'>
Name <input type='text' maxlength='255' name='name' value='First & Last Name' /><br />
E-mail address <input type='text' maxlength='255' name='user'
onBlur='checkUser(this)'/><span id='info'></span><br />
Main Telephone No <input type='text' maxlength='20' name='maintel' value='Tel No' /><br />
Mobile No <input type='text' maxlength='20' name='mobtel' value='Mob No'<br />
Organisation <input type='text' maxlength='255' name='organisation' value='Organisation' /><br />
Group Leader (year)<input type='text' maxlength='255' name='group_leader' value='Year' /><br />
Supervisor <input type='text' maxlength='30' name='supervisor' value='Year' /><br />
Volunteer (Y/N) <input type='text' maxlength='1' name='volunnteer' value='Y/N' /></ br>
Assessor (Y/N) <input type='text' maxlength='1' name='assessor' value='Y/N' /><br />


&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
<input type='submit' value='Submit' />
</form>
_END;

?>


I would be grateful for any help in this.

I am using XAMPP V 1.7.7; Control Panel 3; Windows 7, Service Pack 1

Regards,

'H'
Hamish
 
Posts: 15
Joined: 18. June 2011 21:21
Operating System: Windows 7

Re: Notice: Undefined index: name in C:\xampp\htdocs\temps

Postby Altrea » 19. March 2012 16:42

Hi Hamish,

1st: Please add your OS Information and XAMPP version number to your Profile Info. This will help us to give your the correct support for exactly your environment.

2nd: I bet there are millions of results if you type into Google +php +"Notice: Undefined index:"

Hamish wrote:$name=$_POST['name'];

$_POST['name'] (and any other $_POST index) doesn't exist unless your form is sent.
How should php know, what you want to do if these indexes are not present?

Either check if your form is sent, or check if the index exists before you use it.

best wishes,
Altrea
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11940
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 114 guests