Php 代码表示字段为空,但它们';你不是

Php 代码表示字段为空,但它们';你不是,php,mysqli,Php,Mysqli,我有一张表格,是从我网站的另一个页面上取的,但当我这次尝试使用它时,它返回“不允许有空字段。请返回并正确填写表格。”-所有字段都已填写完毕,我不明白它返回该错误的原因。我想多加一双眼睛可能会有帮助!这是我的完整代码: <?php session_start(); if (isset($_SESSION['USR_LOGIN'])=="") { header("Location:login.php"); } include("mytcg/settings.php"); include(

我有一张表格,是从我网站的另一个页面上取的,但当我这次尝试使用它时,它返回“不允许有空字段。请返回并正确填写表格。”-所有字段都已填写完毕,我不明白它返回该错误的原因。我想多加一双眼睛可能会有帮助!这是我的完整代码:

<?php
session_start();
if (isset($_SESSION['USR_LOGIN'])=="") {    header("Location:login.php");
}
include("mytcg/settings.php");
include("$header"); 
if (!$_SERVER['QUERY_STRING']) { 
    $select = mysqli_query($connect, "SELECT * FROM `$table_members` WHERE email='$_SESSION[USR_LOGIN]'");
while($row=mysqli_fetch_assoc($select)) { ?>
<h1>Claims</h1>
Please take a minute to look through the decks that have already been claimed. If you do not see it on this list, you may go ahead and claim it!<br>

    <?php
    $username = $row['name'];
    $select1 = mysqli_query($connect, "SELECT * FROM `donate` WHERE name='$username'");
    while($row=mysqli_fetch_assoc($select1)) {
        $name1 = $row['name'];
        $claimed1 = $row['series'];
        echo $name1;
        echo $claimed1;
    } ?>
<form action="claimdonation.php?thanks" method="post">
<input type="hidden" name="id" value="<?php echo $row['id']; ?>" />
<input type="hidden" name="name" value="<?php echo $row['name']; ?>" />
<input type="hidden" name="email" value="<?php echo $row['email']; ?>" />
<input type="hidden" name="url" value="<?php echo $row['url']; ?>" />
<table cellspacing="1" cellpadding="2">
<tr>
<td><b>Donation Type:</b></td>
<td><select name="type" size="1">
<option value="" selected="selected">- choose one -</option>
<option value="images">Deck Images</option>
<option value="buttons">Buttons</option>
<option value="badges">Badge Set</option>
<option value="stamp">Stamp Card</option>
</select></td>
</tr>
<tr>
<td><b>Name</b></td>
<td><input type="text" name="series" size="20" /></td>
</tr>
<tr>
<td><b>Category</b></td>
<td><select name="category" size="1">
<option value="" selected="selected">- choose one -</option>
<option value="na" >Not Applicable</option>
<?php
for ($i=1;$i<=$num_categories; $i++) {
echo "<option value=\"$i\">".$category[$i]."</option>";
}
?>
</select></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="submit" value="Claim!">
</tr>
</table>
</form>
<?php } } elseif($_SERVER['QUERY_STRING']=="thanks") {
if (!isset($_POST['submit']) || $_SERVER['REQUEST_METHOD'] != "POST") { exit("<p>You did not press the submit button; this page should not be accessed directly.</p>"); }
else {
$exploits = "/(content-type|bcc:|cc:|document.cookie|onclick|onload|javascript|alert)/i";
$profanity = "-- taken out for bad words --";
$spamwords = "--taken out for bad words--";
$bots = "/(Indy|Blaiz|Java|libwww-perl|Python|OutfoxBot|User-Agent|PycURL|AlphaServer)/i";

if (preg_match($bots, $_SERVER['HTTP_USER_AGENT'])) {
exit("<h1>Error</h1>\nKnown spam bots are not allowed.<br /><br />");
}
foreach ($_POST as $key => $value) {
$value = trim($value);
if (empty($value)) {
exit("<h1>Error</h1>\nEmpty fields are not allowed. Please go back and fill in the form properly.<br /><br />");
}
elseif (preg_match($exploits, $value)) {
exit("<h1>Error</h1>\nExploits/malicious scripting attributes aren't allowed.<br /><br />");
}
elseif (preg_match("#$profanity#", $value) || preg_match("#$spamwords#", $value)) {
exit("<h1>Error</h1>\nThat kind of language is not allowed through our form.<br /><br />");
}
$_POST[$key] = stripslashes(strip_tags($value));
}

$id = escape_sql(CleanUp($_POST['id']));
$name = escape_sql(CleanUp($_POST['name']));
$email = escape_sql(CleanUp($_POST['email']));
$url = escape_sql(CleanUp($_POST['url']));
$type = escape_sql(CleanUp($_POST['type']));
$series = escape_sql(CleanUp($_POST['series']));
$catnum = escape_sql(CleanUp($_POST['category']));
$catname = "$category[$catnum]";

$recipient = "$tcgemail";
$subject = "Claim Form - $name";

$message = "The following member has made a claim: \n";
$message .= "Name: $name \n";
$message .= "Email: $email \n";
$message .= "URL: $url \n";
$message .= "Donation Type: $type \n";
$message .= "Series: $series \n";
$message .= "Category: $catname \n";

$headers = "From: $name \n";
$headers .= "Reply-To: <$email>";
echo "<h1>Thank you!</h1>";
echo "When you are ready to submit your donation, please do so through your member panel.<br><br>";
if(mail($recipient,$subject,$message,$headers)) {
$insert = "INSERT INTO `donate` (`name`, `claimed`, `donated`) VALUES ('$name', '$series', 'No')";
    mysqli_query($connect, $insert);
}
}
} include ("$footer"); ?>

而在另一个while中,因此不能对inside while使用两个变量名相同的“$row”。
更改变量名,如$row1

while($row=mysqli_fetch_assoc($select)) { ?>
......
while($row=mysqli_fetch_assoc($select1)) {

我希望这能有所帮助。

作为旁注:一些变量在“mytcg/settings.php”中声明,请格式化您的代码只需执行
var\u转储($\u POST)查看哪个字段是空的。Alex-你是什么意思?当B.Kocaman解决你的问题时,接受他的答案。我很欣赏你看到这样的未格式化代码。我不会花任何时间在这样的问题上,当人们不能投入更多的时间来正确地格式化他们的代码,以便社区能够更容易地阅读它时。。。