hi everybody,
hope all of u r doing fine..
well, i don’t know what’s the problem in my code! i just followed every step in inserting information from user that shown in most books that teaches PHP .. maybe the problem because of my PHP version (which is 4.0) ..
pla if anyone noticed that there’s mistakes (either syntax or semantics) in the following code, Please let me know..
First Page:
[code=php]
<form method = “post” onsubmit=”return validForm(this)” action = “dedo3.php” >
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> <h3> Order Form </h3> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align = “left” valign = “top”> To <font style = “color:red; size:9pt:”> * </font> :</td>
<td> <input type = “text” name = “to” size = “30”/> </td>
</tr>
<tr>
<td align = “left” valign = “top”> From <font style = “color:red”> * </font> : </td>
<td> <input type = “text” name = “from” size = “30”/> </td>
</tr>
<tr>
<td align = “left” valign = “top”> Customer Name <font style = “color:red”> * </font> : </td>
<td> <input type = “text” name = “customer” size = “30”/> </td>
</tr>
<tr>
<td align = “left” valign = “top”> Address: </td>
<td> <textarea name = “address” cols=”30″ rows=”5″/> </textarea> </td>
</tr>
<tr>
<td align = “left” valign = “top”> Phone <font style = “color:red”> * </font> :</td>
<td> <input type = “text” name = “phone” size = “20”/> </td>
</tr>
<tr>
<td align = “left” valign = “top”> Fax: </td>
<td> <input type = “text” name = “fax” size = “20”/> </td
</tr>
<tr>
<td align = “left” valign = “top”> Contact: </td>
<td> <input type = “text” name = “contact” size = “30”/> </td>
</tr>
<tr>
<td align = “left” valign = “top”> Ship To <font style = “color:red”> * </font> :</td>
<td> <textarea name = “ship” cols=”30″ rows=”5″/> </textarea> </td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td colspan = “2”> <hr width=”95%” size=”1″>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align = “left” valign = “top”> Product ID <font style = “color:red”> * </font> :</td>
<!– ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PHP Select ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ –>
<td>
<select name=”id” cols=”50″ selected = “Select an ID” >
<option value=”Select an ID”> Select an ID </option>
<?php
$link = @mysql_connect(“localhost”, “”, “”);
@mysql_select_db(“plastic”, $link);
$result = mysql_query(“SELECT * FROM products”);
$select = “”;
while( $arow = mysql_fetch_object( $result ) )
{
$select .= “<option value= “$arow->p_id ” > $arow->p_id </option>n”;
}
print $select;
mysql_close($link);
?>
</select>
</td>
</tr>
<tr>
<td align = “left” valign = “top”> Quantity: </td>
<td> <input type = “text” name = “quantity” size = “12”/> </td>
</tr>
<tr>
<td align = “left” valign = “top”> Other Instructions: </td>
<td> <textarea name = “instruction” cols=”30″ rows=”5″/> </textarea> </td>
</tr>
<tr>
<td colspan = “2”> <hr width=”95%” size=”1″>
</tr>
<tr>
<td colspan = “2” align = “right”> <input type = “submit” value = “Send Order” /> </td>
</tr>
</form>
that calls the following one:
[code=php]
<html>
<head>
</head>
<body>
<?php
extract($_POST);
/* $to = $_REQUEST[‘to’]; */
/* $from = $_REQUEST[‘from’]; */
/* $customer = $_REQUEST[‘customer’]; */
/* $address = $_REQUEST[‘address’]; */
/* $phone = $_REQUEST[‘phone’]; */
/* $fax = $_REQUEST[‘fax’]; */
/* $contact = $_REQUEST[‘contact’]; */
/* $ship = $_REQUEST[‘ship’]; */
/* $p_id = $_REQUEST[‘p_id’]; */
/* $quantity = $_REQUEST[‘quantity’]; */
/* $instruction = $_REQUEST[‘instruction’]; */
$link = @mysql_connect(“localhost”, “”, “”);
@mysql_select_db(“plastic”);
$query = “INSERT INTO `pl` (`prid`, `to`, `from`, `customer`, `address`, `phone`, `fax`, `contact`, `ship`, `p_id`, `quantity`, `instruction`) VALUES(‘$to’, ‘$from’, ‘$customer’, ‘$address’, ‘$phone’, ‘$fax’, ‘$contact’, ‘$ship’, ‘$p_id’, ‘$quantity’, ‘$instruction’)”;
if ( ! mysql_query( $query ) )
{
print “Sorry! we couldn’t send your order.n Please try Later” ;
}
else
print “Your order has been sent.nthank you for using our service. We hope you enjoy it”;
mysql_close($link);
?>
</body>
</html>
reGards,
dello