2016-03-23 19 views
-1

değil Sitemde başka bir sayfadan aldığım bir form var, ancak bu kez kullanmaya çalıştığımda "Boş alanlar izin verilmez. Lütfen geri dönün ve formu doğru bir şekilde doldurun. " - tüm alanlar doldurulur ve neden bu hatayı döndürdüğünü anlayamıyorum. Fazladan bir göz setinin faydalı olabileceğini düşündüm! Bu tam kodum:Kod alanları boş, ancak onlar

<?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"); ?> 
+0

Bir yan not olarak: bazı değişkenler "mytcg/settings.php" –

+0

içinde bildirilmiştir. Lütfen kodunuzu biçimlendirin –

+1

Sadece bir "var_dump ($ _POST);", hangi alanın boş olduğunu görmek için. – Technoh

cevap

2

içeride bir süre içerideyken, bu arada değişken adını içeride '$ row' ile aynı anda kullanamazsınız. Ben bu yardımı umut $ row1

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

gibi değişken adını değiştirin .

+0

Teşekkür ederim! Tam olarak ne oldu! –

+2

Bu tür biçimlendirilmemiş kodlara baktığınızı takdir ediyorum. Toplumun daha kolay okuyabilmesi için insanların kodlarını düzgün bir şekilde biçimlendirmek için birkaç dakika daha yatırım yapamadıkları zaman böyle sorulara hiç vakit harcamıyorum. –

İlgili konular