Greetings:
I have a form that is supposed to pass the data to a page to be processed and entered into mysql... I keep getting this:
Data inserted successfully.INSERT INTO license (quantity, lic_num, sw_id, purch_date, exp_date, po_num, auth_num, notes) VALUES ('','','','','','','','')
but there is data in the form when it is submitted.
Register globals is off and I prefer to leave it like that 🙂
Any help would be appreciated.
This is the form page:
<FORM action="insertlic.php" method="post">
<table>
<tr><td><b>License number: </B></td><td><input type="text" name="lic_num" size=25></td></tr>
<tr><td><b>Quantity: </B></td><td><input type="text" name="quantity" size=25></td></tr>
<tr><td><b>Software Name: </B></td><td>
<?php
$db = mysql_connect("$server", "$user", "$password");
mysql_select_db('ktdlicense', $db) or die ('Cannot connect to $db_Database : ' . mysql_error());
$result = mysql_query ("SELECT sw_id, sw_name
FROM sw
ORDER BY sw_name") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$sw_name = $row['sw_name'];
$sw_id = $row['sw_id'];
$optionList .= "<option value=". $sw_id .">". $sw_name ."</option>";
}
echo '<form method = "POST"
action = "insertlic.php">';
echo "<select name=swid>";
echo $optionList;
echo "</select>";
?>
<tr><td><b>Purchase date: </B></td><td><input type="text" name="purch_date" size=25>yyyy-mm-dd</td></tr>
<tr><td><b>Expiration date: </B></td><td><input type="text" name="exp_date" size=25>yyyy-mm-dd</td></tr>
<tr><td><b>PO#: </B></td><td><input type="text" name="po_num" size=25></td></tr>
<tr><td><b>Auth #: </B></td><td><input type="text" name="auth_num" size=25></td></tr>
</table>
<BR>
<BR>
<input type="submit" value="Submit">
</FORM>
This is the process page:
<?php
$sw_id = $_post['swid'];
include 'c:\Program Files\Apache Group\Apache2\htdocs\ktd\inc\my.php';
$db = mysql_connect("$server", "$user", "$password");
mysql_select_db('ktdlicense', $db) or die ('Cannot connect to $db_Database : ' . mysql_error());
$result = mysql_query ("SELECT sw_id, sw_name
FROM sw
WHERE sw_id = '$swid'") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
$sw_id = $row['sw_id'];
$sw_name = $row['sw_name'];
}
?>
<?PHP
mysql_select_db('ktdlicense', $db) or die ('Cannot connect to $db_Database : ' . mysql_error());
$quantity = $_post['quantity'];
$lic_num = $_post['lic_num'];
$swid = $_post['sw_id'];
$purch_date = $_post['purch_date'];
$exp_date = $_post['exp_date'];
$po_num = $_post['po_num'];
$auth_num = $_post['auth_num'];
$notes = $_post['notes'];
$sql = "INSERT INTO license (quantity, lic_num, sw_id, purch_date, exp_date, po_num, auth_num, notes)
VALUES ('$quantity','$lic_num','$sw_id','$purch_date','$exp_date','$po_num','$auth_num','$notes')";
$sql_result = mysql_query($sql,$db) or die ('Could not insert data');
echo('Data inserted successfully.');
echo $sql;
mysql_close($db);
?>