我正在处理的项目基本上涉及输入框并将它们存储到mysql数据库中。我试图使用JavaScript来生成此表单,如果需要可以添加另一个表单。我想我遇到的问题是让它为第二个生成的表单分配一个不同的“名称”。 ex红色,red1,red2等。然后也试图让这个与php-mysqli一起工作。多次生成相同的输入
到目前为止,我已经能够将它发布到表格中,但它将值发布在第二组输入框中。 有人可以提供一些建议吗?
<form id="color_form" action="postcolors.php" method="post">
<input id="name" class="color_entry" action="postcolors.php" method="post" name="name" placeholder="song name" style="background-image: url("data:image/png;base64,iVBORw0KGgoAAAA…nt: scroll; background-position: right center; cursor: auto;"></input>
<input id="red" class="color_entry" action="" method="post" name="red" placeholder="red"></input>
<input id="green" class="color_entry" action="" method="post" name="green" placeholder="green"></input>
<input id="blue" class="color_entry" action="" method="post" name="blue" placeholder="blue"></input>
<input id="color" class="color_entry" action="" method="post" name="color" placeholder="color"></input>
<input id="name" class="color_entry" action="postcolors.php" method="post" name="name" placeholder="song name"></input>
<input id="red" class="color_entry" action="" method="post" name="red" placeholder="red"></input>
<input id="green" class="color_entry" action="" method="post" name="green" placeholder="green"></input>
<input id="blue" class="color_entry" action="" method="post" name="blue" placeholder="blue"></input>
<input id="color" class="color_entry" action="" method="post" name="color" placeholder="color"></input>
<input type="submit" value="submit" action="postcolors.php" method="post"></input>
</form>
$song=mysqli_real_escape_string($connect, $_POST['name']);
$song = str_replace(' ', '', $song);
mysqli_query($connect, "CREATE TABLE $song (id int(4) NOT NULL auto_increment, red int(2) NOT NULL, green int(2) NOT NULL, blue int(2) NOT NULL, color varchar(30) NOT NULL, index(id))");
$red=mysqli_real_escape_string($connect, $_POST['red']);
$green=mysqli_real_escape_string($connect, $_POST['green']);
$blue=mysqli_real_escape_string($connect, $_POST['blue']);
$color=mysqli_real_escape_string($connect, $_POST['color']);
mysqli_query($connect, "INSERT INTO $song (red,green,blue,color) VALUES ('$red', '$green', '$blue', '$color')");
您不能重复ID,ID =“名称”只能在页面中出现一次。 – Fahad 2014-10-17 11:38:15