Click here to Skip to main content
15,889,931 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have created a simple php program which includes textbox and if user input something and hit the submit button...
the data will be added to the MySql database..

Simple as that.........

here is my code :



XML
<html>
 <head>
  <title>PHP Test</title>
 </head>
<form method="post" action="input.php">
  Name: <input type="text" name="name" size="20">
<!--  Address: <input type="text" name="address" size="40">-->
<input type="submit" name="submit"  value="Sent">
</form>
 <body>
 <?php

 //the example of inserting data with variable from HTML form
mysql_connect("localhost","root","promod19861030");//database connection
mysql_select_db("empdata");

// Get values from form
$Fname=$_POST['name'];
//$address = $_POST['address'];

//inserting data order
$order = "INSERT INTO empname
       (empName)
      VALUES
       ('$Fname')";

//declare in the order variable
$result = mysql_query($order);  //order executes
if($result)
{
 echo("
Input data is succeed");
}
else
{
 echo("
Input data is fail");
}

 ?>
 </body>
</html>


and i have Mysql datatable with 2 columns
id will automatically increment
name will be added from the textbox

but when i execute this

Notice: Undefined index: name in C:\xampp\htdocs\newEmptyPHP1.php on line 18
Input data is succeed

this notification and
after i input something and hit submit, it'll show

Object not found!

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error.

If you think this is a server error, please contact the webmaster.
Error 404
localhost
Apache/2.4.7 (Win32) OpenSSL/1.0.1e PHP/5.5.6....

please help me to solve this case.............
Posted
Comments
Killzone DeathMan 2-Jan-14 5:56am    
Hello..
$_POST['name] is undefined!
If you open the page the first time, its undefined, but when you submit the form its okay!
You can protect this Notice like:

if(isset($_POST['name]))
{
echo 'The variable "name" is set ;)';
}
else
echo 'The variable "name" is NOT set!';

1 solution

Check the reason for this error
PHP - Notice: Undefined index[^]

FYI
Troubleshooting PHP errors[^]
HTTP 404[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900