this is my code for inserting records into my form which is in html file
Inline Code Example Here

<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$connect=mysql_connect("localhost","root","") or die(mysql_error());
$db_select=mysql_select_db("employee",$connect) or die(mysql_error());

if (isset($_POST['id'])) 

$id=$_POST['id'];
if (isset($_POST['name'])) 
$name=$_POST['name'];
if (isset($_POST['gender'])) 
$gender=$_POST['gender'];
if (isset($_POST['mobile'])) 
$mobile=$_POST['mobile'];
if (isset($_POST['email'])) 
$email=$_POST['email'];
$qry="insert into emp(id,name,gender,mobile,email) values ('$id','$name','$gender',$mobile,'$email')";
$result=mysql_query($qry)  or die(mysql_error());

if($result)
{
echo "DETAILS ADDED SUCCESSFULLY";
}
else
{
echo "TRY AGAIN";
}

?>

undefined index means you tried to access an array position that didn't exist. E.g. $array[10] when $array only has five elements. Associative arrays have the same problem e.g. trying to get $array['bob'] when that isn't in the array.

Which lines is giving the error? At a glance your code looks OK

thanks

this is my html file for form
<html>
<title> EMPLOYE DETAILS</title>

<body>

<fieldset style=text-align:left>
<form name=empdetails id=empdetails action=page2.php method=POST>

 ID : <input type=text id=id name=id ><br>

 NAME :<input type=text id=name name=name ><br>
 GENDER :
<input type=radio id=gender name=gender value=f>FEMALE<br>
 <input type=radio  id=gender1 name=gender value=m> MALE<br>
MOBILE NO <input type=text id=mobile name=mobile ><br>
EMAIL ID <input type=email id=email name=email >
<br>
 <input type=submit id=submit name=submit><br>
 </form>
<form name=empdetails id=empdetails action=page3.php>
  <input type=submit id=submit name=view value=view ><br>

 </form>
 <form name=empdetails id=empdetails action=page4.php>
  <input type=submit id=submit name=view value=UPDATE ><br>

 </form>
  <form name=empdetails id=empdetails action=page5.php>
  <input type=submit id=submit name=view value=DELETE ><br>

 </form>

</body>

</html>


my php code for insert

<?php
error_reporting(E_ALL ^ E_DEPRECATED);

$connect=mysql_connect("localhost","root","") ;

$db_select=mysql_select_db("employee",$connect) ;
  if (isset($_POST['id']) && isset($_POST['name']) && isset($_POST['gender']) && isset($_POST['mobile']) &&isset($_POST['email']));
{

$id=$_POST['id'];

$name=$_POST['name'];

$gender=$_POST['gender'];

$mobile=$_POST['mobile'];

$email=$_POST['email'];

$qry="insert into emp(id,name,gender,mobile,email) values('$id', '$name', '$gender','$mobile','$email')";
$result=mysql_query($qry) or die(mysql_error());

if($result)
{
echo "DETAILS ADDED SUCCESSFULLY";
}
else
{
echo "TRY AGAIN";
}
}
?>
 im geting undefined index error for all my variable ($id,$name,$gender,$mobile,$email)
 my database structure is 
 +--------+-------------+------+-----+---------+-------+
| Field  | Type        | Null | Key | Default | Extra |
+--------+-------------+------+-----+---------+-------+
| id     | varchar(5)  | NO   | PRI | NULL    |       |
| name   | varchar(25) | NO   |     | NULL    |       |
| gender | varchar(1)  | NO   |     | NULL    |       |
| mobile | int(10)     | NO   |     | NULL    |       |
| email  | varchar(25) | NO   |     | NULL    |       |
+--------+-------------+------+-----+---------+-------+

i tried in many ways but it is showing undeifed index error when i use post method .i checked with request method it is acceting value .

how come your html doesn't have double quotes "" or singel quotes '' ?

<input type="text" id="name" name="name" >

or did u just omit them for this post?

thank you so much i havent noticed that quote ..

Please my program same as that but still showing undefined index I have tried so many ways is not working plsss I need help.

commented: This response 6 years later? Time for a new discussion. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.