内部使用のために作成したフォームがあります。フォームからのデータを MySQL データベースに取り込むことができました。また、ID キー (この場合は数値) に基づいてデータをフィールドに戻す検索機能も作成しました。すべてのテキスト フィールドはフィールドに戻りますが、テキスト エリア データは戻りません。MySQL データベースにアクセスすると、それらのテキスト エリアのテーブル フィールドが入力されていますが、フォームに引き戻されていないようです。できれば助けてください。ありがとうございました。
私のHTMLフォーム:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>- - = = EPC Print Order Form = = - - </title>
</head>
<body bgcolor="#DFDFD9">
<h1>Digital Print Form    <input type="image" src="http://commonmedia.asicentral.com/180000/182101/EPC_KAPP.jpg"></h1>
<!-- form to get key detail of record in database -->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Request RFQ</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><form name="form" method="POST" action="form1.php">
RFQ#:</td><td><input type="text" name="search"></td><td><input type="submit" value="submit"></td>
</form></tr></table>
</fieldset>
<!--------------------- Print Form Data ------------------>
<form action="mysqlTest.php" method="post" id="prayfrm" name="prayfrm" onsubmit="return checkform(this);" onreset="return confirm('Do you want to clear this form?')">
<input type="hidden" name="drfq" value="6">
<!--********** Basic Job Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Job Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="drepid">Sales Rep</label></td>
<td><input type="text" name="drepid" size="30" required="true"/>
</td>
<td><label>Today's Date</label></td>
<td><input type="text" name="datepicker" size="10"/></td>
</tr>
<tr>
<td><label for="repemail">Rep Email</label></td>
<td><input id="repemail" name="repemail" type="text" size="30" required="true" /></td>
<td><label>Date Needed</label></td>
<td><input id="dateneeded" name="dateneeded" type="text" size="10" required="true" /> </td>
</tr>
<tr>
<td><label for="description">Description</label></td>
<td><input id="description" name="description" type="text" size="30" required="true" /></td>
<td><label for="qty">Quantity</label></td>
<td><input id="qty" name="qty" type="text" size="10" required="true" /></td>
</tr>
<tr>
<td><label for="pgsizeh">Page Size (h) x (w)</label></td>
<td><input id="pgsizeh" name="pgsizeh" type="text" size="10" required="true" /> x <input id="pgsizew" name="pgsizew" type="text" size="13" required="true" /></td>
<td><label for="pageno">Page Number</label></td>
<td><input id="pageno" name="pageno" type="text" size="10" required="true" /></td>
</tr>
<tr>
<td><label for="stock">Stock</label></td>
<td><input id="stock" name="stock" type="text" size="10" required="true" />  <label for="stock">Color   </label>
<input type="text" name="ink" size="6" required="true"/>
</td>
<td><label for="inknote">   Explain </label></td>
<td><input id="inknote" name="inknote" type="text" size="10" /></td>
</tr>
<tr>
<td><label for="rfq">Referenced RFQ:</label></td>
<td><input id="rfq" name="rfq" type="text" size="10" required="true" /><td><label for="finishing">Finishing</label></td>
<td><input id="finishing" name="finishing" type="text" size="10" required="true" />
</tr>
</table></fieldset>
<!--********** Customer Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Customer Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="dfirstname">First Name</label></td><td><input id="dfirstname" name="dfirstname" type="text" size="31" required="true" /></td><td><label for="dlastname">  Last </label></td><td><input id="dlastname" name="dlastname" type="text" size="31" required="true" /></td>
</tr>
<tr>
<td><label for="dorganization">Organization</label></td>
<td><input id="dorganization" name="dorganization" type="text" size="31" required="true" /></td><td><label for="email">Email</label></td>
<td><input id="email" name="email" type="text" size="31" required="true" /></td>
</tr>
<tr>
<td><label for="daddress1">Address</label></td><td><input id="daddress1" name="daddress1" type="text" size="31" required="true" /><td></td><td><input id="daddress2" name="daddress2" type="text" size="31" />
</tr>
<tr>
<td><label for="dcity">City</label></td><td><input id="dcity" name="dcity" type="text" size="25" required="true" /> <label for="dstate"> State</label></td><td><input id="dstate" name="dstate" type="text" size="3" required="true" /> <td><label for="dzip"> Zip </label> <input id="dzip" name="dzip" type="text" size="27" required="true" /></tr>
<tr>
<td><label for="phone">Phone </label><td><input id="phone" name="phone" type="text" size="31" required="true" /></td><td><label for="fax">Fax </label><td><input id="fax" name="fax" type="text" size="31" required="true" /> </td>
</tr></table></fieldset>
<!--********** Delivery Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Delivery Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="proof">Proof?</label>  <input type="checkbox" name="proof" value="yes" required="true" />  </td><td><label for="whoproof">Proof to Whom?</label> <input id="whoproof" name="whoproof" type="text" size="44" required="true" /></td>
</tr>
<tr>
<td><label for="quote">Quote?</label> <input type="checkbox" name="quote" value="yes" required="true" />  </td>
<td><label for="amount">Amount: $</label> <input id="amount" name="amount" type="text" size="50" required="true" /></td>
</tr>
<tr>
<td><label for="delivery">Delivery Instructions</label></td><td><textarea name="delivery" rows="4" cols="50"></textarea></tr>
<tr>
<td><label for="notes">Additional Notes</label></td><td><textarea name="notes" rows="4" cols="50"></textarea>
</tr>
<td align="right"><input name="submit" type="submit" id="submit" value="Submit" /></td>
<td align="left"><input name="Reset" type="reset" id="reset" value="Reset Form" /></table></fieldset>
</body>
</html>
データベースにフィールドを追加するための私の PHP ファイル
<?php
$dbhost = 'hostname';
$dbuser = 'username';
$dbpass = '*******';
$conn = mysql_connect($dbhost, $dbuser, $dbpass) or die ('Error connecting to mysql');
$dbname = 'dbasename';
mysql_select_db($dbname);
// -------------------------------------------------------------------
// Field Names
// -------------------------------------------------------------------
$drepid=mysql_real_escape_string($_POST['drepid']);
$datepicker=mysql_real_escape_string($_POST['datepicker']);
$repemail=mysql_real_escape_string($_POST['repemail']);
$dateneeded=mysql_real_escape_string($_POST['dateneeded']);
$description=mysql_real_escape_string($_POST['description']);
$qty=mysql_real_escape_string($_POST['qty']);
$pgsizeh=mysql_real_escape_string($_POST['pgsizeh']);
$pgsizew=mysql_real_escape_string($_POST['pgsizew']);
$pageno=mysql_real_escape_string($_POST['pageno']);
$stock=mysql_real_escape_string($_POST['stock']);
$ink=mysql_real_escape_string($_POST['ink']);
$inknote=mysql_real_escape_string($_POST['inknote']);
$rfq=mysql_real_escape_string($_POST['rfq']);
$finishing=mysql_real_escape_string($_POST['finishing']);
$dfirstname=mysql_real_escape_string($_POST['dfirstname']);
$dlastname=mysql_real_escape_string($_POST['dlastname']);
$dorganization=mysql_real_escape_string($_POST['dorganization']);
$email=mysql_real_escape_string($_POST['email']);
$daddress1=mysql_real_escape_string($_POST['daddress1']);
$daddress2=mysql_real_escape_string($_POST['daddress2']);
$dcity=mysql_real_escape_string($_POST['dcity']);
$dstate=mysql_real_escape_string($_POST['dstate']);
$dzip=mysql_real_escape_string($_POST['dzip']);
$phone=mysql_real_escape_string($_POST['phone']);
$fax=mysql_real_escape_string($_POST['fax']);
$proof=mysql_real_escape_string($_POST['proof']);
$whoproof=mysql_real_escape_string($_POST['whoproof']);
$quote=mysql_real_escape_string($_POST['quote']);
$amount=mysql_real_escape_string($_POST['amount']);
$delivery=mysql_real_escape_string($_POST['delivery']);
$notes=mysql_real_escape_string($_POST['notes']);
$sql = "INSERT INTO epc_print (drepid, datepicker, repemail, dateneeded, description, qty, pgsizeh, pgsizew, pageno, stock, ink, inknote, rfq, finishing, dfirstname, dlastname, dorganization, email, daddress1, daddress2, dcity, dstate, dzip, phone, fax, proof, whoproof, quote, amount, delivery, notes) values ('$drepid', '$datepicker', '$repemail', '$dateneeded', '$description', '$qty', '$pgsizeh', '$pgsizew', '$pageno', '$stock', '$ink', '$inknote', 'rfq', '$finishing', '$dfirstname', '$dlastname', '$dorganization', '$email', '$daddress1', '$daddress2', '$dcity', '$dstate', '$dzip', '$phone', '$fax', '$proof', '$whoproof', '$quote', '$amount', '$delivery', '$notes')";
mysql_query($sql) or die(mysql_error());
echo "
<code><pre></code>";
echo "POST:";
print_r($_POST);
echo "<code></pre></code>
";
echo "1 record added";
?>
次に、データを取得するための私のphpファイル:
<?php
$connection = mysql_connect('hostname','username','*****') or die ("Couldn't connect to server.");
$db = mysql_select_db('databasename', $connection) or die ("Couldn't select database.");
$search=$_POST['search'];
$data = 'SELECT * FROM `epc_print` WHERE `drfq` = "'.$search.'"';
$query = mysql_query($data) or die("Couldn't execute query. ". mysql_error());
$data2 = mysql_fetch_array($query);
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>- - = = EPC Print Form = = - - </title>
</head>
<body bgcolor="#DFDFD9">
<h1>Digital Print Form    <input type="image" src="http://commonmedia.asicentral.com/180000/182101/EPC_KAPP.jpg"></h1>
<!-- form to get key detail of record in database -->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Request RFQ</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><form name="form" method="POST" action="form1.php">
RFQ#:</td><td><input type="text" name="search"></td><td><input type="submit" value="submit"></td>
</form></tr></table>
</fieldset>
<!--------------------- Print Form Data ------------------>
<form action="form2.php" method="post" id="prayfrm" name="prayfrm" onsubmit="return checkform(this);" onreset="return confirm('Do you want to clear this form?')">
<input type="hidden" name="drfq" value="6">
<!--********** Basic Job Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Job Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="drepid">Sales Rep</label></td>
<td><input id="drepid" name="drepid" type="text" size="30" value="<?php echo htmlspecialchars ($data2[drepid])?>" required="true" /></td>
</td>
<td><label>Today's Date</label></td>
<td><input id="datepicker" name="datepicker" type="text" size="10" value="<?php echo htmlspecialchars ($data2[datepicker])?>" required="true" /></td>
</tr>
<tr>
<td><label for="repemail">Rep Email</label></td>
<td><input id="repemail" name="repemail" type="text" size="30" value="<?php echo htmlspecialchars ($data2[repemail])?>" required="true" /></td>
<td><label>Date Needed</label></td>
<td><input id="dateneeded" name="dateneeded" type="text" size="10" value="<?php echo htmlspecialchars ($data2[dateneeded])?>" required="true" /></td></td>
</tr>
<tr>
<td><label for="description">Description</label></td>
<td><input id="description" name="description" type="text" size="30" value="<?php echo htmlspecialchars ($data2[description])?>" required="true" /></td>
<td><label for="qty">Quantity</label></td>
<td><input id="qty" name="qty" type="text" size="10" value="<?php echo htmlspecialchars ($data2[qty])?>"required="true" /></td>
</tr>
<tr>
<td><label for="pgsizeh">Page Size (h) x (w)</label></td>
<td><input id="pgsizeh" name="pgsizeh" type="text" size="10" value="<?php echo htmlspecialchars ($data2[pgsizeh])?>" required="true" /> x <input id="pgsizew" name="pgsizew" type="text" size="14" value="<?php echo htmlspecialchars ($data2[pgsizew])?>" required="true" /></td>
<td><label for="pageno">Page Number</label></td>
<td><input id="pageno" name="pageno" type="text" size="10" value="<?php echo htmlspecialchars ($data2[pageno])?>" required="true" /></td>
</tr>
<tr>
<td><label for="stock">Stock</label></td>
<td><input id="stock" name="stock" type="text" size="10" value="<?php echo htmlspecialchars ($data2[stock])?>" required="true" /> <label for="ink">Color </label> <input id="ink" name="ink" type="text" size="10" value="<?php echo htmlspecialchars ($data2[ink])?>" required="true" /></td>
<td><label for="inknote">   Explain </label></td>
<td><input id="inknote" name="inknote" type="text" size="10" value="<?php echo htmlspecialchars ($data2[inknote])?>"/></td>
</tr>
<tr>
<td><label for="rfq">Referenced RFQ:</label></td>
<td><input id="rfq" name="rfq" type="text" size="10" value="<?php echo htmlspecialchars ($data2[rfq])?>" required="true"/></td> <td><label for="finishing">Finishing</label></td>
<td><input id="finishing" name="finishing" type="text" size="10" value= "<?php echo htmlspecialchars ($data2[finishing])?>" required="true" />
</tr>
</table></fieldset>
<!--********** Customer Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Customer Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="dfirstname">First Name</label></td><td><input id="dfirstname" name="dfirstname" type="text" size="31" value="<?php echo htmlspecialchars ($data2[dfirstname])?>" required="true" /></td><td><label for="dlastname">  Last </label></td><td><input id="dlastname" name="dlastname" type="text" size="31" value= "<?php echo htmlspecialchars ($data2[dlastname])?>"required="true" /></td>
</tr>
<tr>
<td><label for="dorganization">Organization</label></td>
<td><input id="dorganization" name="dorganization" type="text" size="31" value="<?php echo htmlspecialchars ($data2[dorganization])?>" required="true" /></td><td><label for="email">Email</label></td>
<td><input id="email" name="email" type="text" size="31" value="<?php echo htmlspecialchars ($data2[email])?>" required="true" /></td>
</tr>
<tr>
<td><label for="daddress1">Address</label></td><td><input id="daddress1" name="daddress1" type="text" size="31" value="<?php echo htmlspecialchars ($data2[daddress1])?>" required="true" /><td></td><td><input id="daddress2" name="daddress2" type="text" size="31" value="<?php echo htmlspecialchars ($data2[daddress2])?>"/>
</tr>
<tr>
<td><label for="dcity">City</label></td><td><input id="dcity" name="dcity" type="text" size="25" value="<?php echo htmlspecialchars ($data2[dcity])?>" required="true" /> <label for="dstate"> State</label></td><td><input id="dstate" name="dstate" type="text" size="3" value="<?php echo htmlspecialchars ($data2[dstate])?>" required="true" /> <td><label for="dzip"> Zip </label> <input id="dzip" name="dzip" type="text" size="27" value="<?php echo htmlspecialchars ($data2[dzip])?>" required="true" /></tr>
<tr>
<td><label for="phone">Phone </label><td><input id="phone" name="phone" type="text" size="31" value="<?php echo htmlspecialchars ($data2[phone])?>" required="true" /></td><td><label for="fax">Fax </label><td><input id="fax" name="fax" type="text" size="31" value="<?php echo htmlspecialchars ($data2[fax])?>"/> </td>
</tr></table></fieldset>
<!--********** Delivery Information for the form******************-->
<fieldset style='width:570px; text-align:left; border-width:2px;'>
<legend><h3>Delivery Information</h3></legend>
<table bgcolor="beige" border="0" width="570px">
<tr>
<td><label for="proof">Proof?</label>  <input type="checkbox" name="proof" value="<?php echo ($data2[proof])?>" />  </td><td><label for="whoproof">Proof to Whom?</label> <input id="whoproof" name="whoproof" type="text" size="44" value="<?php echo htmlspecialchars ($data2[whoproof])?>"required="true" /></td>
</tr>
<tr>
<td><label for="quote">Quote?</label> <input type="checkbox" name="quote" value="<?php echo htmlspecialchars ($data2[quote])?>" required="true" />  </td>
<td><label for="amount">Amount: $</label> <input id="amount" name="amount" type="text" size="50" value="<?php echo htmlspecialchars ($data2[amount])?>" required="true" /></td>
</tr>
<tr>
<td><label for="delivery">Delivery Instructions</label></td><td><textarea name="delivery" rows="4" cols="50" value="<?php echo htmlspecialchars ($data2[delivery])?>" /></textarea></tr>
<tr>
<td><label for="notes">Additional Notes</label></td><td><textarea name="notes" rows="4" cols="50" value="<?php echo htmlspecialchars ($data2[notes])?>"/></textarea>
</tr>
<td align="right"><input name="submit" type="submit" id="submit" value="Submit" /></td>
<td align="left"><input name="Reset" type="reset" id="reset" value="Reset Form" /></table></fieldset>
</body>
</html>