I'm trying to use a form and drop downs to send data to a database table named "computers"
Here's where I'm at, the errors say
Undefined index: name
Undefined index: category
Undefined index: category found here:
$name = $_POST['name'] ;
$category = $_POST['category'] ;
if ($_POST['category']
Isn't it reading these fields in the form? Can someone see why the php isn't reading these named form fields? Am I supposed to have some php in the form itelf? Thanks very, very, much.
PHP Code:PHP Code:
<?php
ini_set('error_reporting', 8191);
ini_set('display_startup_errors', 1);
ini_set('display_errors', 1);{
?>
</span>
<form action="<?php $_SERVER['PHP_SELF'] ;?>" method="post">
<table>
<tbody>
<tr>
<td><input name="name" size="25"/></td>
</tr>
<tr>
<td>
<select name="category">
<option value="first">first</option>
<option value="second">second</option>
<option value="third">third</option>
</select>
</td>
</tr>
<tr>
<td><input value="Add" type="submit" /></td>
</tr>
</tbody>
</table>
</form>
<?php
}
$con = mysql_connect("","","");
if (!$con)
{ die('Could not connect: ' . mysql_error());
}
mysql_select_db("", $con);
$name = $_POST['name'] ;
$category = $_POST['category'] ;
if ($_POST['category'] == 'first'){
$sql="INSERT INTO computers (name,category,date)
VALUES ('" . $_POST['name'] . "','" . $_POST['category'] . "',CURDATE())";
if (mysql_query($sql,$con))
{echo "row added";}
else if (!mysql_query($sql,$con)) {mysql_error();}}
?>




Bookmarks