这是我用来打开一个带有变量 $query_string 的弹出窗口的代码,该变量用于保存表单中的条目。
echo'<script language = "JavaScript" type="text/javascript">
//<![CDATA[
window.open(\'./save.php?'.$query_string.'\',\'save\',\'location=no,menubar=no,resizable=yes,scrollbars=yes,status=yes\');
然后我用 save.php 显示一个提交按钮并编写了一个插入语句将数据放入数据库中。问题是数据库表中的行被填充为 0。犯了任何错误吗?
if($_POST['formSubmit'] == "Submit")
{
//appending the date to store in the database.
$entry_date_array = array($_REQUEST["year"],$_REQUEST["month"],$_REQUEST["day"]);
$entry_date = implode('-', $entry_date_array);
echo "$entry_date";
//appending aggr nr and fetching the id from the database.
$aggr_nr = $_REQUEST['list_nr_01'].$_REQUEST['list_nr_02'].$_REQUEST['list_nr_03'];
$sql="SELECT v.id FROM aggregatenumber AS v WHERE v.aggr_nr = '".$aggr_nr."'";//missing Quotes
$aggr_id = @mysql_query($sql);
$result = @mysql_fetch_array($aggr_id);
$test= $result['id'];
echo "$test";
$sql_einl_sp = "INSERT INTO search_parts(entry_date,aggr_nr)values('".$entry_date."','".$test."')";
$result_einl_sp = @mysql_query($sql_einl_sp);
html
<body>
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post">
<h>Save Information</h>
<input type="submit" name="formSubmit" value="Submit" />
<input type="submit" name="btncancel" value="Cancel"/>
</form>
</body>