- 爱易网页
-
PHP教程
- 遇见过重复插入数据的请进
日期:2014-05-17 浏览次数:20418 次
遇见过重复插入数据的大虾请进!
问题是这样的,我用Php写了一个表单,然后在提交的处理页面执行一条insert语句,但是我到数据看的时候发现每次插入的都是两条记录,郁闷了一个下午了,希望遇见过这类问题的大侠能帮忙解决一下。我的提交表单的文件如下所示:
<?php session_start();?>
<html>
<head>
<title>图书馆管理系统</title>
<link href="CSS/style.css" rel="stylesheet">
</head>
<script language="javascript">
function check(form){
if(form.barcode.value==""){
alert("请输入条形码1!");form.barcode.focus();return false;
}
if(form.bookName.value==""){
alert("请输入图书姓名!");form.bookName.focus();return false;
}
if(form.price.value==""){
alert("请输入图书定价!");form.price.focus();return false;
}
form.submit();
}
</script>
<body>
<table width="776" border="0" align="center" cellpadding="0" cellspacing="0" class="tableBorder">
<tr>
<td>
<?php include("navigation.php");?>
</td>
</tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td valign="top" bgcolor="#FFFFFF"><table width="99%" height="510" border="0" align="center" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" class="tableBorder_gray">
<tr>
<td height="510" align="center" valign="top" style="padding:5px;"><table width="98%" height="487" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="22" valign="top" class="word_orange">当前位置:图书档案管理 > 添加图书信息 >>></td>
</tr>
<tr>
<td align="center" valign="top"><table width="100%" height="493" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="top">
<form name="form1" method="post" action="book_ok.php">
<table width="600" height="432" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
<tr>
<td width="173" align="center">条 形 码:</td>
<td width="427" height="39">
<input name="barcode" type="text" id="barcode"></td>
</tr>
<tr>
<td align="center">图书名称:</td>
<td height="39"><input name="bookName" type="text" id="bookName" size="50"> * </td>
</tr>
<tr>
<td align="center">图书类型:</td>
<td>
<select name="typeId" class="wenbenkuang" id="typeId">
<?php
include("Conn/conn.php");
$sql=mysql_query("select * from tb_booktype");
$info=mysql_fetch_array($sql);
do{
?>
<option value="<?php echo $info[id];?>"><?php echo $info[typename];?></option>
<?php }while($info=mysql_fetch_array($sql));?>
</select>
</td>