clint6998 Posted April 9, 2013 Share Posted April 9, 2013 Hello from the newbie! I have a form that I need to post the data to my MySQL db and it is not working. It says that it uploaded it, but it doesn't upload the data. Strange thing is that when I go to re-enter the information, it says that the serial number is already in the system. Here is the php process: <?php if($_POST['doSubmit'] == 'Add') { $rs_dup = mysql_query("select count(*) as total from firearms where serialNumber='$post[serialNumber]'") or die(mysql_error()); list($dups) = mysql_fetch_row($rs_dup); if($dups > 0) { die("That Serial Number already exists in the system."); } mysql_query("INSERT INTO `firearms` (`manufacturer`,`model`,`serialNumber`,`caliber`,`type`,`receiptDate`) VALUES ('$post[manufacturer]','$post[model]','$post[serialNumber]','$post[caliber]','$post[type]',now()) ") or die(mysql_error()); echo "<div class=\"msg\">New Firearm Added....done.</div>"; } ?> Here is the form: <p><?php if(!empty($msg)) { echo $msg[0]; } ?></p> <table width="100%" border="0" cellpadding="5" cellspacing="2" class="myaccount"> <tr> <td width="50%" style="text-align:right"><form name="addNew" id="addNew" method="post" action="new.php">Name of Manufacturer and/or Importer: </td> <td width="50%" style="text-align:left"><input name="manufacturer" type="text" id="manufacturer"></td> </tr> <tr> <td style="text-align:right">Model of Firearm: </td> <td style="text-align:left"><input name="model" type="text" id="model" class="required"></td> </tr> <tr> <td style="text-align:right">Firearm Serial Number: </td> <td style="text-align:left"><input name="serialNumber" type="text" id="serialNumber" class="required"></td> </tr> <tr> <td style="text-align:right">Caliber or Gauge of Firearm: </td> <td style="text-align:left"><input name="caliber" type="text" id="caliber" class="required"></td> </tr> <tr> <td style="text-align:right">Type of Firearm (pistol, revolver, shotgun, rifle,etc.): </td> <td style="text-align:left"><input name="type" type="text" id="type" class="required"></td> </tr> <tr> <td colspan="2" style="text-align:center"><input name="doSubmit" type="submit" id="doSubmit" value="Add"></form></td> </tr> </table> Here is the db structure: CREATE TABLE IF NOT EXISTS `firearms` ( `id` bigint(20) NOT NULL AUTO_INCREMENT, `manufacturer` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '', `model` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '', `serialNumber` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '', `caliber` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '', `type` varchar(200) COLLATE latin1_general_ci NOT NULL DEFAULT '', `receiptDate` date NOT NULL DEFAULT '0000-00-00', PRIMARY KEY (`id`), UNIQUE KEY `serialNumber` (`serialNumber`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci AUTO_INCREMENT=1 ; Attached is an image of what whose up when the form is processed. It is making an entry, but only populates the 'id' and 'date' fields. Any help would be greatly appreciated!!! Thanks, CLint Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted April 9, 2013 Share Posted April 9, 2013 it's $_POST not $post Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.