My fields in the cmsdevices table are as follows:
ID (primary)
companyID
device
desc
connect
features
thearticle
This code is based from the article written by Peter Zeidman http://www.intranetjournal.com/articles/200407/ij_07_06_04a.html
Here's my code:
Code: Select all
<?php
// --- data entry code
// Get the PHP file containing the DbConnector class
require_once('../includes/DbConnector.php');
// Check whether a form has been submitted. If so, carry on
if ($HTTP_POST_VARS){
// Create an instance of DbConnector
$connector = new DbConnector();
// Create an SQL query (MySQL version)
$insertQuery = "e;INSERT INTO cmsdevices (companyID,device,desc,connect,features,thearticle) VALUES ("e;.
"e;'"e;.$HTTP_POST_VARSї'companyID']."e;', "e;.
"e;'"e;.$HTTP_POST_VARSї'device']."e;', "e;.
"e;'"e;.$HTTP_POST_VARSї'desc']."e;', "e;.
"e;'"e;.$HTTP_POST_VARSї'connect']."e;', "e;.
"e;'"e;.$HTTP_POST_VARSї'features']."e;', "e;.
"e;'"e;.$HTTP_POST_VARSї'thearticle']."e;')"e;;
}
// Save the form data into the database
if ($result = $connector->query($insertQuery)){
// It worked, give confirmation
echo '<p><center>Company added to the database</center>';
}else{
// It hasn't worked so stop. Better error handling code would be good here!
exit('<p><center>Sorry, there was an error saving to the database</center>');
}
?>
<form enctype="e;multipart/form-data"e; name="e;Devices"e; method="e;POST"e; action="e;newdevice.php"e;>
<div class="e;row"e;><span class="e;label"e;>
<?php
$sql="e;SELECT id,company FROM cmscompany ORDER BY company"e;;
$result=mysql_query($sql);
$options="e;"e;;
while ($row=mysql_fetch_array($result)) {
$id=$rowї"e;id"e;];
$company=$rowї"e;company"e;];
$options.="e;<option value=\"e;$id\"e;>"e;.$company.'</option>';
}
?>
<select name="e;companyID"e; id="e;companyID"e; /><option value="e;0"e;>Choose Company<?=$options?></select></span></div>
<div class="e;row"e;><span class="e;label"e;>Device:</span><span class="e;formw"e;><input name="e;device"e; type="e;text"e; size="e;35"e; id="e;device"e; /></span></div>
<div class="e;row"e;><span class="e;label"e;>Description:</span><span class="e;formw"e;><textarea name="e;desc"e; cols="e;30"e; rows="e;6"e; id="e;desc"e;></textarea></span></div>
<div class="e;row"e;><span class="e;label"e;>Connectivity:</span><span class="e;formw"e;><input name="e;connect"e; type="e;text"e; size="e;35"e; id="e;connect"e; /></span></div>
<div class="e;row"e;><span class="e;label"e;>Features:</span><span class="e;formw"e;><textarea name="e;features"e; cols="e;30"e; rows="e;6"e; id="e;features"e;></textarea></span></div>
<div class="e;row"e;><span class="e;label"e;>Specifications:</span><span class="e;formw"e;><textarea name="e;thearticle"e; cols="e;30"e; rows="e;6"e; id="e;thearticle"e;></textarea></span></div>
<div class="e;row"e;><span class="e;formw"e;><input type="e;submit"e; name="e;action"e; value="e;Submit"e; /> <input type="e;reset"e; value="e;Reset Form"e; /></span></div>
<div class="e;spacer"e;> </div>
</form>I've gone over my code for over a week now and I just can't get this to work. It's the very last step I need to do to finish this project, and I'm just stuck. Any advice, help, or even just a comment would really help me out. Thank you all in advance!
Cheers,
Rob