You are here: Form not working properly after adding new table columns to DB « All PHP « IT news, forums, messages
Form not working properly after adding new table columns to DB

Posted by sloane.irwin on 09/28/20 11:48

I've added about 19 fields to the database, and after modifying the
form to include all values and then modifying the db_update.php file to
search for and update all values, I go to the site, enter information,
click submit, and it reverts me back to the database display and the
new information is nowhere to be found, even when I click refresh.
Here's my form code:

<html>
<head>
<title>New Computer Entry</title>
</head>
<body>

<form method="get" action="db_update.php">
<label>Inventory#
<input type="text" name="inventory">
</label>
<p>
<label>First Name
<input type="text" name="first">
</label>
</p>
<p>
<label>Last Name
<input type="text" name="last">
</label>
</p>
<p>
<label>Serial #
<input type="text" name="serial">
</label>
</p>
<p>
<label>Location
<input type="text" name="location">
</label>
</p>
<p>
<label>Brand
<input type="text" name="brand">
</label>
</p>
<p>
<label>Model
<input type="text" name="model">
</label>
</p>
<p>
<label>E-Mail
<input type="text" name="email">
</label>
</p>
<p>
<label>Date Entered(YYYY-MM-DD)
<input type="date" name="date_entered">
</label>
</p>
<p> <br />
<input type="submit" value="Submit">
</p>
</form>

</body>
</html>



And here's the db_connect.php code:

<html>
<body>
<?
require('db_login.php');
require('db_connect.php');

// the table you want to add to

$table = 'data';


// begin the query

$query = "INSERT INTO $table(";


// add fieldnames to insert

$query = $query . 'inventory' . ', ';
$query = $query . 'date_entered' . ', ';
$query = $query . 'first' . ', ';
$query = $query . 'last' . ', ';
$query = $query . 'serial' . ', ';
$query = $query . 'city' . ', ';
$query = $query . 'brand' . ', ';
$query = $query . 'model' . ', ';
$query = $query . 'email';
$query = $query . 'building';
$query = $query . 'room';
$query = $query . 'computer_name';
$query = $query . 'pri_user';
$query = $query . 'buy_date';
$query = $query . 'warranty';
$query = $query . 'vendor';
$query = $query . 'os';
$query = $query . 'processor';
$query = $query . 'memory';
$query = $query . 'hd';
$query = $query . 'drive1';
$query = $query . 'drive2';
$query = $query . 'drive3';
$query = $query . 'drive4';
$query = $query . 'comments';



// end fieldnames and begin values

$query = $query . ') VALUES(';


// get values from $_REQUEST

$query = $query . '"' . $_REQUEST['inventory'] . '", ';
$query = $query . '"' . $_REQUEST['date_entered'] . '", ';
$query = $query . '"' . $_REQUEST['first'] . '", ';
$query = $query . '"' . $_REQUEST['last'] . '", ';
$query = $query . '"' . $_REQUEST['serial'] . '", ';
$query = $query . '"' . $_REQUEST['city'] . '", ';
$query = $query . '"' . $_REQUEST['brand'] . '", ';
$query = $query . '"' . $_REQUEST['model'] . '", ';
$query = $query . '"' . $_REQUEST['email'] . '", ';
$query = $query . '"' . $_REQUEST['building'] . '", ';
$query = $query . '"' . $_REQUEST['room'] . '", ';
$query = $query . '"' . $_REQUEST['computer_name'] . '", ';
$query = $query . '"' . $_REQUEST['pri_user'] . '", ';
$query = $query . '"' . $_REQUEST['buy_date'] . '", ';
$query = $query . '"' . $_REQUEST['warranty'] . '", ';
$query = $query . '"' . $_REQUEST['vendor'] . '", ';
$query = $query . '"' . $_REQUEST['os'] . '", ';
$query = $query . '"' . $_REQUEST['processor'] . '", ';
$query = $query . '"' . $_REQUEST['memory'] . '", ';
$query = $query . '"' . $_REQUEST['hd'] . '", ';
$query = $query . '"' . $_REQUEST['drive1'] . '", ';
$query = $query . '"' . $_REQUEST['drive2'] . '", ';
$query = $query . '"' . $_REQUEST['drive3'] . '", ';
$query = $query . '"' . $_REQUEST['drive4'] . '", ';
$query = $query . '"' . $_REQUEST['comments'] . '"';


// end query

$query = $query . ')';


// run INSERT query

mysql_query($query, $db);

include('db_close.php');
?>

<script language="javascript">
<!--

location.href = 'display2.php';

//-->
</script>
</body>
</htm

Any ideas? I'm a php/MySQL noob...

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация