Hi All,
I am a newbie so please bare with me, Thanks! - I am trying to create a simple INSERT throug a FORM and I am getting empty fields into the DataBase, it inserts a record line but no DATA, the proccess is: 1 Form Page calls 1 Process Page here:
Form Page : additem.php
<html>
<head>
<title>xxxxxxxxxxxx</title>
<style type="text/css">
<!--
.input {
font-family: "Arial", "Helvetica", "sans-serif";
font-size: 11px;
border: 1px solid #339900;
}
-->
</style>
<link rel="STYLESHEET" type="text/css" href="zi3.css">
<?PHP
function WriteDateSelect($BeginYear = 1998,
$EndYear = 2007,
$IsPosted = true,
$Prefix = '')
{
if (! $BeginYear)
{
$BeginYear = date('Y');
}
if (! $EndYear)
{
$EndYear = $BeginYear;
}
$Year = $IsPosted
? (int) $_POST[$Prefix . 'Year']
: (int) $_GET[$Prefix . 'Year'];
$Month = $IsPosted
? (int) $_POST[$Prefix . 'Month']
: (int) $_GET[$Prefix . 'Month'];
$Day = $IsPosted
? (int) $_POST[$Prefix . 'Day']
: (int) $_GET[$Prefix . 'Day'];
echo '<select name="', $Prefix, 'Year">
';
for ($i = $BeginYear; $i <= $EndYear; $i++)
{
echo '<option ';
if ($i == $Year)
echo 'selected="yes"';
echo '>', $i, '</option>
';
}
echo '</select>-
<select name="', $Prefix, 'Month">
';
for ($i = 1; $i <= 12; $i++)
{
echo '<option ';
if ($i == $Month)
echo 'selected="yes"';
echo '>', $i, '</option>
';
}
echo '</select>-
<select name="', $Prefix, 'Day">
';
for ($i = 1; $i <= 31; $i++)
{
echo '<option ';
if ($i == $Day)
echo 'selected="yes"';
echo '>', $i, '</option>
';
}
echo '</select>
';
return;
}
?>
</head>
<body bottommargin="0" leftmargin="10" marginheight="10" marginwidth="10" rightmargin="0" topmargin="10">
<h3>Please enter the information below to ADD the new item</h3>
<FORM NAME="additem" ACTION="itemADD.php" METHOD="POST">
<table align="left" cellspacing="2" cellpadding="2" border="0">
<tr>
<td><span class="contents">Services Type: </span></td>
<td><select name="servicestype" size="1" >
<option value="">-- Select Type --</option>
<option value="C">Connectivity</option>
<option value="D">Data Center</option>
<option value="H">Hosting</option>
<option value="N">Network</option>
<option value="O">Office</option>
<option value="W">Wireless</option>
</select></td>
</tr>
<tr>
<td><span class="contents">Asset Type: </span></td>
<td><select name="assettype" size="1">
<option value="">-- Select Type --</option>
<option value="Antenna">Antenna</option>
<option value="Hub/Switch">Hub/Switch</option>
<option value="Modem">Modem</option>
<option value="PC">PC</option>
<option value="Peripherals">Peripherals</option>
<option value="Phone">Phone</option>
<option value="Router">Router</option>
<option value="Server">Server</option>
<option value="Software">Software</option>
<option value="W. Hardware">W. Hardware</option>
<option value="Other">Other</option>
</select></td>
</tr>
<tr>
<td><span class="contents">Manufacturer: </span></td>
<td><input type="Text" name="manufacturer" required="No" size="30" maxlength="50" ></td>
</tr>
<tr>
<td><span class="contents">Model: </span></td>
<td><input type="Text" name="model" required="No" size="30" maxlength="50"></td>
</tr>
<tr>
<td><span class="contents">Date Purchased: </span></td>
<td>
<? WriteDateSelect(1998, 2007, true, 'purchased'); ?>
</td>
</tr>
<tr>
<td><span class="contents">Purchased Price: </span></td>
<td><input type="Text" name="price" message="Please enter a Purchased Price!" validate="integer" required="Yes" size="10" maxlength="10"> <span class="contents">(CAD)</span></td>
</tr>
<tr>
<td><span class="contents">Leased / Owned: </span></td>
<td><select name="leaseown" size="1">
<option value="">-- Select --</option>
<option value="leased">Leased</option>
<option value="owned">Owned</option>
</select></td>
</tr>
<tr>
<td><span class="contents">Location: </span></td>
<td><select name="location" size="1">
<option value="">-- Select Location --</option>
<option value="Client">Client</option>
<option value="DataCenter">Data Center</option>
<option value="Network">Network</option>
<option value="Office">Office</option>
<option value="StoreRoom">Store Room</option>
</select></td>
</tr>
<tr>
<td><span class="contents">Assigned to: </span></td>
<td><input type="Text" name="userid" required="No" size="30" maxlength="50"></td>
</tr>
<tr>
<td><span class="contents">Date Assigned: </span></td>
<td>
<? WriteDateSelect(2001, 2007, true, 'dateassigned'); ?>
</td>
</tr>
<tr>
<td><span class="contents">Client Address: </span></td>
<td><input type="Text" name="clientaddress" required="No" size="30" maxlength="50"></td>
</tr>
<tr>
<td><span class="contents">Client Status: </span></td>
<td><select name="leaseown" size="1">
<span class="contents"><option value="">-- Select --</option>
<option value="Active">Active</option>
<option value="Deactivated">Deactivated</option>
</select></span></td>
</tr>
<tr>
<td valign="top"><span class="contents">Comments: </span></td>
<td><textarea name="comments" rows="7" cols="23"></textarea></td>
</tr>
<tr>
<tr>
<td valign="top" colspan="2" align="center"><input type="Submit" value="ADD"> <input type="Reset" value="CLEAR"></td>
</tr>
<tr>
<td colspan="2" align="center"><span class="bot">xxxxx
<?=date("Y")?>
© All Rights Reserved</span></td>
</tr>
</table>
</body>
</html>
Process Page: itemADD.php
<?
$DBhost = "xx.xxx.xxx.xx";
$DBuser = "userOK";
$DBpass = "passOK";
$DBName = "DBnameOK";
$table = "tableOK";
mysql_connect($DBhost,$DBuser,$DBpass) or die("Unable to connect to database");
@mysql_select_db("$DBName") or die("Unable to select
database $DBName");
$date = date(Y-m-d);
$sqlquery = "INSERT INTO $table (Service_Type,Asset_Type,Manufacturer,Model,Date_Purchased,Price,Location,Date_Assigned,Client_Address,Status,User_ID,Comments,Leaseown,Date_entered)
VALUES('$servicetype','$assettype','$manufacturer','$model','$purchased',$price,'$location','$assigned','$clientaddress','$status','$userid','$comments','$leaseown','$date') ";
$results = mysql_query($sqlquery);
mysql_close();
print "<HTML><TITLE> PHP and MySQL </TITLE><BODY
BGCOLOR=\"#FFFFFF\"><center><table border=\"0\"
width=\"500\"><tr><td>";
print "<p><font face=\"verdana\" size=\"+0\"> <center>You
Just Entered This Information Into the
Database<p><blockquote>";
print "AssetType : $assettype<p>Model : $model<p>Comments :
$comments</blockquote></td></tr></table>
</center></BODY></HTML>";
?>
----------------------------
Please HELP!!!, Gift Certificates for BEER available!! he he
Thanks!
Fxmaster:p