我有两个文件,csform.php 和 process.php。Csform.php 是用户将在数据中输入并点击提交的表单的主页,然后我有 process.php 和 sql 连接,我希望将用户输入表单的数据插入到 sql server数据库。但是当点击提交时,没有插入表单中输入的数据,而是插入了process.php文件第13行的数据。我做错了什么,似乎这两个文件之间没有联系。这是我目前拥有的编码:
csform.php:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>CSLog</title>
</head>
<h1> Customer Service Form </h1>
<form method="post" action="process.php">
<table width="300" border="0">
<tr>
<td> Forte ID:</td>
<td><select id="forteid" input name="forteid">
<option value="user1">user1</option>
<option value="user2">user2</option>
<option value="user3">user3</option>
<option value="user4">user4</option>
</select></td>
</tr>
<tr>
<td> Disposition</td>
<td><select id="disposition" input name="disposition">
<option value="Save">--Save--</option>
<option value="Sale">--Sale--</option>
<option value="LOC">--LOC--</option>
</select> </td>
</tr>
</table>
<br />
<hr />
<br />
<br />
<table width="400" border="0">
<tr>
<td>App Number:</td>
<td></td>
<td><input type="text" name="appnumber"></td>
</tr>
<tr>
<td>Finance Number:</td>
<td></td>
<td><input type="text" name = "Finance_Num"></td>
</tr>
<tr>
<td>Number Payments:</td>
<td></td>
<td><input type="text" name = "num_payments"></td>
</tr>
<tr>
<td>Ach or CC:</td>
<td></td>
<td><input type="text" name = "ach_cc"></td>
</tr>
<tr>
<td>Date:</td>
<td></td>
<td><input type="text" name = "date"></td>
</tr>
</table>
<br />
Notes:
<br />
<textarea input name="text" id="notes" cols="45" rows="5"></textarea>
</fieldset>
<br />
<br />
<hr />
<br />
<br />
<input type="submit" name="formSubmit" value="Submit"> <input type="Reset" name="formReset" value="Reset">
</form>
</head>
<body>
</body>
</html>
然后是process.php:
<?php
$serverName = 'SRB-Nick_Desktop\SQLEXPRESS';
$connectionInfo = array('Database'=>'cslogs', 'UID'=>'cslogslogin', 'PWD'=>'123456');
$connection = sqlsrv_connect($serverName, $connectionInfo);
if( $connection === false )
{
echo "Connection could not be established.\n";
die( print_r( sqlsrv_errors(), true));
}
$tsql = "INSERT INTO logs(ForteID, disposition, appnumber, Finance_Num, num_payments, ach_cc, date, notes) VALUES (?,?,?,?,?,?,?,?)";
$parameters = array( "forteid", "LOC", "NCXXXXXXX4", "SRB-000004", "0", "cc", "2012-11-01", "gave LOC instructions");
$stmt = sqlsrv_query($connection, $tsql, $parameters);
if( $stmt === false ){
echo "Statement could not be executed.\n";
die( print_r( sqlsrv_errors(), true));
} else {
echo "Rows affected: ".sqlsrv_rows_affected( $stmt )."\n";
}
/* Free statement and connection resources. */
sqlsrv_free_stmt( $stmt);
sqlsrv_close( $connection);
?>
希望有人能够帮助我或引导我在我做错的事情上朝着正确的方向前进。