Jump to content

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


jas21
Go to solution Solved by 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:

Edited by jas21
Link to comment
Share on other sites

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");

	}
}
?>

Link to comment
Share on other sites

  • Solution

 

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. :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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