ForensicCashew
New Member
Hello all,
I am trying to build a PHP form that includes a script to post the input information into a database.
PHP script:
and the form:
Can someone please tell me what I am doing wrong? I can't seem to find my mistake. I'm a PHP noob but i'm trying very hard to learn.
I am trying to build a PHP form that includes a script to post the input information into a database.
PHP script:
Code:
<?php
//Connect To Database
$hostname="[censored].hostedresource.com";
$username="[censored]";
$password="[censored]";
$dbname="[censored";
$usertable="[censored";
mysql_connect($hostname,$username, $password) OR DIE ('Unable to connect to database! Please try again later.');
mysql_select_db($dbname);
$sql="INSERT INTO registrants (Fname, Lname, Business, Address, Ptnumber, Quantity, Duedate)
VALUES
('$_POST[Fname]','$_POST[Lname]','$_POST[Business]','$_POST[Address]','$_POST[Ptnumber]','$_POST[Quantity]','$POST_[Duedate)'))";
if($result)
{
while($row = mysql_fetch_array($result))
{
$name = $row["$yourfield"];
echo "Name: ".$name."<br>";
}
}
?>
and the form:
Code:
<form action="http://www.bktoolco.com/phpform.php" method="post">
<table width="300" border="1">
<tr>
<td>First Name:</td>
<td><input name="Fname" type="text" id="Fname" size="40" /></td>
</tr>
<tr>
<td>Last Name:</td>
<td><input name="Lname" type="text" id="Lname" size="40" /></td>
</tr>
<tr>
<td>Business:</td>
<td><input name="Business" type="text" id="Business" size="40" /></td>
</tr>
<tr>
<td>Address:</td>
<td><label>
<input name="Address" type="text" id="Address" size="40">
</label></td>
</tr>
<tr>
<td>Part Number:</td>
<td><label>
<input name="Ptnumber" type="text" id="Ptnumber" size="40">
</label></td>
</tr>
<tr>
<td>Quantity:</td>
<td><label>
<input name="Quantity" type="text" id="Quantity" size="40">
</label></td>
<tr>
<td>Due Date</td>
<td><label>
<input name="Duedate" type="text" id="Duedate" size="40">
</label></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td><input type="submit" /></td>
</tr>
</table>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
</form>