|
I swear thought this code would work, but when I hit my 'ADD' button the screen blinks and nothing happens. The info that I inputted into the form field disappears. It is like the action=filename doesn't work, because I am not being redirected. Even if I go to mysql command line client and do a SELECT * from ups; (which is one of the tables) it shows an empty set. Can someone help please, because I am now on a time table and I don't know what else to do. Here is the html form and the php file:
HTML form:
<html>
<BODY BGCOLOR=#3399CC>
<head>
<title>CHS Master Inventory System</title>
</head>
<TABLE Border=
<B><FONT SIZE=10><CENTER>CHS Master Inventory</CENTER></FONT SIZE></B>
<h1><i><u><center>UPS Table</center></u></i></h1>
<form method="POST" action="http://localhost/newUpsRec.php">
<fieldset>
<legend><b>UPS Information</b></legend>
<b>ID:</b><input type=text name="id" size="15">
<b>Room/Area:</b><input type=text name="rmArea">
<b>CHS ID:</b><input type=text name="chsId" size="4">
<b>Model:</b><input type=text name="model" size="12"><br/><br/>
<b>Serial:</b><input type=text name="serial" size="15">
<b>Manufacturer:</b><input type=text name="manuf">
</fieldset><br/>
<input type='submit' value='ADD'><BR>
</form>
</body>
</html>
php file:
<html>
<head>
<title>CHS Master Inventory System</title>
</head>
<body bgcolor="#3399CC">
<?php
/* set's the variables for MySQL connection */
$dbhost = "localhost:3306"; // this is the server address and port
$dbuname = "root";// username
$dbpass = "hoover"; // password
$dbname = "chs";
/* Connects to the MySQL server */
$dbase = mysql_connect($dbhost, $dbuname, $dbpass) or die ("Could not connect to SQL Server");
/* Defines the Active Database for the Connection */
mysql_select_db($dbname, $dbase)
$id=$_POST['id']; $rmArea=$_POST['rmArea']; $chsid=$_POST['chsID']; $model=$_POST['model']; $serial=$_POST['serial']; $manuf=$_POST['manuf'];
$results = "INSERT INTO ups (id, room/area, chs id, model, serial, manuf) values ($id, $rmArea, $chsid, $model, $serial, $manuf)";
mysql_query($results);
echo "Record has been added.<br><a href="upsTBL.html">Click here</a>to return to UPS Table<br>";
mysql_close($dbase);
?>
</body>
</html>
|