Jump to content

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


jas21

Recommended Posts

Hello experts,

   I am running with an app and i have some notice error while inserting records.

My form code is pasted below:

<form action="add_bk_insert.php">

Name <input type="text"  name="name"/><br />
E-mail <input type="text"  name="email" /><br />
Contact <input type="text"  name="contact" /><br />
Requirement <input type="text"  name="requirement" /><br />

<input type="submit" value="Submit" />

</form>

and my add_bk_insert.php code is as shown below:

<?php

mysql_connect("localhost","root","");

mysql_select_db("test");

$order = "INSERT INTO sal2

            (name,email_id, contact,requirement)

            VALUES

            ('$_POST[name]','$_POST[email_id]','$_POST[contact]','$_POST[requirement]')";

$result = mysql_query($order); 

if($result){

 echo "Inserted";   
 //include_once("testimonials.php");
} else{

    echo("<br>Input data is fail");

}
?>

when i run the above code it shows a notice error as below:

Notice: Undefined index: name 

Notice: Undefined index: email_id 

Notice: Undefined index: contact 

Notice: Undefined index: requirement 

So i dont know what exactly i am missing. Please some one can help me out with this. 

I am really stuck. :sweat:

try replacing this code

<form action="add_bk_insert.php">
Name <input type="text"  name="name"/><br />
E-mail <input type="text"  name="email" /><br />
Contact <input type="text"  name="contact" /><br />
Requirement <input type="text"  name="requirement" /><br />
<input type="submit" value="Submit" name="btnSubmit"/>
</form>
<?php
mysql_connect("localhost","root","");
mysql_select_db("test");
if (isset($_POST['btnSubmit']))
{
	$name = isset($_POST[name]) ? $_POST[name] : '';
	$email_id = isset($_POST[email_id]) ? $_POST[email_id] : '';
	$contact = isset($_POST[contact]) ? $_POST[contact] : '';
	$requirement = isset($_POST[requirement]) ? $_POST[requirement] : '';
	$order = "INSERT INTO sal2 (name,email_id, contact,requirement) VALUES('".$name."','".$email_id."','".$contact."','".$requirement."')";
	$result = mysql_query($order); 
	if($result)
	{
	 echo "Inserted";   
	 //include_once("testimonials.php");
	} else{

		echo("<br>Input data is fail");

	}
}
?>

 

try replacing this code

<form action="add_bk_insert.php">
Name <input type="text"  name="name"/><br />
E-mail <input type="text"  name="email_id" /><br />
Contact <input type="text"  name="contact" /><br />
Requirement <input type="text"  name="requirement" /><br />
<input type="submit" value="Submit" name="btnSubmit"/>
</form>
<?php
mysql_connect("localhost","root","");
mysql_select_db("test");
if (isset($_POST['btnSubmit']))
{
	$name = isset($_POST[name]) ? $_POST[name] : '';
	$email_id = isset($_POST[email_id]) ? $_POST[email_id] : '';
	$contact = isset($_POST[contact]) ? $_POST[contact] : '';
	$requirement = isset($_POST[requirement]) ? $_POST[requirement] : '';
	$order = "INSERT INTO sal2 (name,email_id, contact,requirement) VALUES('".$name."','".$email_id."','".$contact."','".$requirement."')";
	$result = mysql_query($order); 
	if($result)
	{
	 echo "Inserted";   
	 //include_once("testimonials.php");
	} else{

		echo("<br>Input data is fail");

	}
}
?>

 

 

Thanks a lot of replying. But did u run the code because the serverside script is not working. Or may be i am wrong. But i do tried it out and not working for me. :(

Archived

This topic is now archived and is closed to further replies.

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