我有问题。当我什么都不提交到mysql数据库时。矩阵可以与不同的证书名称相同。实际上,我尝试使用数组但我无法配置它...请帮助我
<html>
<head>
<script language="javascript">
fields = 0;
function addInput() {
if (fields != 10) {
document.getElementById('text').innerHTML += "<br/><input type='text' name='cer[]' size='30' />";
fields += 1;
} else {
document.getElementById('text').innerHTML += "<br />Maximum 10 fields allowed.";
document.form.add.disabled=true;
}
}
</script>
</head>
<body>
<form action="" method="post">
<div id="text"><p>matric</p>
<input type="text" name="matric" size="30" />
<div id="text"><p>Certificate name</p>
<input type="text" name="cer[]" size="30" />
<br />
<input type="button" onclick="addInput()" name="add" value="Add input field" />
<input type="submit" value="Submit" name="sumbit"/>
</div>
</form>
<?php
include 'dbconnect.php';
if (isset($_POST['submit'])){
$Matric = addslashes($_POST['Matric']);
$Cer_name = addslashes($_POST['cer[]']);
if(!empty($Cer_name)){
$query = "INSERT INTO certificate (Matric,Cer_name) VALUE ('$Matric','$Cer_name')";
$result = mysql_query($query);
}
}
?>
</body>
</html>