每次用户单击表单中的提交按钮时,我都会尝试将新信息输入数据库。它工作得很好,但只能工作一次。所以它会在数据库中输入一行,然后如果用户再次填写表格并单击提交,则不会将任何信息输入到数据库中,直到我删除前一行,所以如果数据库为空,它就可以工作。这是我将其输入数据库的代码,如果您需要更多信息来帮助让我知道我会给您评分,一切都提前谢谢
if($_POST['submit']){
$query = mysql_query("SELECT * FROM chanels WHERE cname = '$cname'");
$numrows = mysql_num_rows($query);
if($numrows == 1) {
echo "You Channel has already been added. Go back your <a
href='./memberpage.php'>Station Page.</a>";
}else{
if($_POST['description']){
$description = $_POST['description'];
if(strlen($description) < 250 ){
$code = $_GET['code'];
$category = $_POST['category'];
mysql_query("INSERT INTO chanels VALUES
('','$code','$cname','$category','$description',''
)");
echo "You Channel has been added. Go back your <a
href='./memberpage.php'>Station Page.</a>";
}else
echo "Your description must be less than 250 characters!";
}else
echo "You must enter a description!";
}
}