У меня есть следующий код, и он отображает опции тега выбора как $level1promo_competition
в зависимости от того, что находится в моей базе данных. Меня удивляет то, что если я изменил имя в моей базе данных или моей переменной на другое, отличное от того, что есть в моей базе данных, я не смогу заставить $resultCheck
отображать значение 1 ... и он должен перенаправить меня, потому что он не соответствует базе данных ....
<?php
include_once __DIR__.'/header2.php';
if(!isset($_SESSION['u_uid'])) {
echo "<meta http-equiv='refresh' content='0;url=index.php?level1promoform_form2=notlogin'>";
exit();
} else {
if(!isset($_POST['submit'])) {
header("Location: level1promoform.php?level1promoform_form2=error");
exit();
} else {
include_once __DIR__.'/includes/dbh.php';
$level1promo_competition =
strip_tags($_POST['level1promo_competition']);
if ($level1promo_competition == 'January\'s Competition') {
$sql = "SELECT * FROM level1promo WHERE name = ?;";
$stmt = mysqli_stmt_init($conn);
if(!mysqli_stmt_prepare($stmt, $sql)) {
echo "SQL error";
} else {
mysqli_stmt_bind_param($stmt, "s", $level1promo_competition);
mysqli_stmt_execute($stmt);
$result = mysqli_stmt_get_result($stmt);
$resultCheck = mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result);
echo $resultCheck;
if($resultCheck < 1) {
echo "<meta http-equiv='refresh' content='0;url=level1promoform.php?level1promoform_form2=error'>";
exit();
} else {
echo '<form action="level1promoform_form2_process.php" method="POST">
<table class="admin_level1promoform_form2">
<tr>
<th colspan="2" class="update_title">Welcome to the Administrator\'s Level 1 Promo Competition Form\' Section</th>
</tr>
<tr>
<th>Competition Entry ID:</th><td>',htmlspecialchars($row['id']),'</td>
</tr>
<tr>
<th>Competition\'s Name:</th><td>',htmlspecialchars($row['name']),'</td>
</tr>
<tr>
<th>Competition\'s opening date:</th><td>',htmlspecialchars($row['opening_date']),'</td>
</tr>
<tr>
<th>Competition\'s closing date:</th><td>',htmlspecialchars($row['closing_date']),'</td>
</tr>
<tr>
<th>Competition\'s Points\' Required:</th><td>',htmlspecialchars($row['points']),'</td>
</tr>
<tr>
<th>Enter Points Amount:</th><td><input type="text" name="amount" value="Enter Amount"></td>
</tr>
<tr>
<th></th><td><input type="submit" name="submit" value="Submit Competition"</td>
</tr>
</table>
</form>';
}
}
}
}
}