繁体   English   中英

我现在将表单数据从php文件回显到html表单,我想更新对MYSQL的更改

[英]I echo form data from a php file to html form now i want to update changes to MYSQL

我有一个通过服务器端php文件填充的表单,此回显是MYSQL记录中的所有字段和数据

echo '<li class="form-line" id="id_21"><label class="form-label-left" id="label_21" for="input_21"> Customer Job Details </label><div id="cid_21" class="form-input">';
echo '<table>';
echo '<tr>';

echo '<td><label class="form-sub-label" for="first_3" id="sublabel_first"> Customers Name </label><input type="text" id="CustomerName" value="' . $rows['CustomerName'] . '"></td>';
echo '<td><label class="form-sub-label" for="first_3" id="sublabel_first"> Signing Date </label><input type="text" id="SignDate" value="' . $rows['SignDate'] . '"></td>';

echo '<td><label class="form-sub-label" for="first_3" id="sublabel_first"> OrderNumber </label><input type="text" name="OrderNumber" id="OrderNumber" value="' . $rows['OrderNumber'] . '"></td>';
echo '</tr>';
echo '<tr>';
echo '<td><label class="form-sub-label" for="first_3" id="sublabel_first"> Current Account Status </label><input type="text" id="CustomerStatus" value="' . $rows['CustomerStatus'] . '"></td>';
echo '<td><label class="form-sub-label" for="first_3" id="sublabel_first"> Customer Last Updated </label><input type="text" class=" form-textbox" data-type="input-textbox" id="input_21" name="CustomerLastUpdate" size="20" value="' . $rows['LastUpdated'] . '" /></td>';
echo '<td><label class="form-sub-label" for="first_3" id="sublabel_first"> Contact Email </label><input type="text" id="OrderNumber" name="Email" size="25" value="' . $rows['Email'] . '"></td>';
echo '</tr>';
echo '</table>';


echo '<li class="form-line" id="id_4"><label class="form-label-left" id="label_4" for="input_4"> Company Name </label><div id="cid_4" class="form-input">';
    echo '<label class="form-sub-label" for="first_3" id="sublabel_first"> Company Name </label><input type="text" class=" form-textbox" data-type="input-textbox" id="input_4" name="q4_companyName4" size="40" value="' . $rows['CompanyName'] . '" />';
    echo '</div>';
    echo '</li>';

echo '<li class="form-line" id="id_5">
        <label class="form-label-left" id="label_5" for="input_5"> Address </label>

我建立了一个小的测试文件以在... Update.html更新

    <html>
    <form method="post" name="update" action="Update.php" />
       Address1:
       <input type="text" name="Address1" />
       OrderNumber:
       <input type="text" name="OrderNumber" />
       <input type="submit" name="Submit" value="update" />
   </form>

还有一个名为Update.php的服务器端文件

                  or die("Could not select examples");
     $Add1 = $_POST["q5_address5[addr_line1]"];
     $Add2 = $_POST["Address1"];
     $Order = $_POST['OrderNumber'];
     $query = "UPDATE CurrentJobs SET StreetAddress = '$Add1' WHERE OrderNumber = '$Order'";

      if(mysql_query($query)){
     echo "updated '$Add1''$Add2' Value";}
     else{
    echo "fail";}
     ?>

这两个测试文件在我的数据库上运行良好,并且似乎是因为我从服务器端文件中echo了数据,所以我没有得到正确的更新。 echo$Add1值,它为空,它还会手动清除我放置在该字段中的所有数据,因此似乎正在返回“”

任何建议,我做错了,将不胜感激。

我在html表单中放置了一个POST方法

    <form class="xxxxxx" action="Update.php" method="post" name="update" id="UpdateFrorm" accept-charset="utf-8">
        <button id="input_2" type="submit" class="form-submit-button form-submit-button-metal_brushed">
          Submit
        </button>

我也曾尝试将更新按钮放置在php文件中,但仍然没有喜悦...

    echo '<div style="text-align:center" class="form-buttons-wrapper">
<form class="xxxxxxx" action="Update.php" method="post" name="update" id="UpdateFrorm" accept-charset="utf-8">
        <button id="input_2" type="submit" class="form-submit-button form-submit-button-metal_brushed">
          Submit
        </button>
        &nbsp;
         <button id="input_print_2" style="margin-left:25px;" class="form-submit-print form-submit-button-metal_brushed" type="button">
          <img src="http://cdn.jotfor.ms/images/printer.png" align="absmiddle" />
          Print Form
        </button>
        <INPUT TYPE="Submit" VALUE="Update the Record" NAME="Submit">
      </div>';     

您没有将q5_address5[addr_line1]发布到Update.php

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM