nav pills
unknown
php
3 years ago
15 kB
57
Indexable
<div class="container" style="margin-top: 10px;">
<!-- Nav tabs -->
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link active" data-bs-toggle="pill" href="#sidebar-ad">Sidebar - Ad</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#home-top-ad">Home Top Ad</a>
</li>
<li class="nav-item">
<a class="nav-link" data-bs-toggle="pill" href="#set">Setting</a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane container active" id="sidebar-ad">
<form action="" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="ad_title">Record Name:</label>
<input value="<?php echo $db_sidebar_rec_title; ?>" class="form-control" type="text" name="sidebar_ad_title" required>
</div>
<div class="form-group">
<label for="ad_title">Advertisement method</label>
<br>
<input value="adsense" type="radio" name="method" <?php if ($db_sidebar_ad_method == 'adsense') {
echo 'checked';
} ?>>Adsense
<br>
<input value="custom" type="radio" name="method" <?php if ($db_sidebar_ad_method == 'custom') {
echo 'checked';
} ?>>Custom
</div>
<script>
$("input[type='radio']").change(function() {
if ($(this).val() == "adsense") {
$("#adsense").show();
$("#custom").hide();
$("#action").hide();
} else if ($(this).val() == "custom") {
$("#custom").show();
$("#action").show();
$("#adsense").hide();
}
// else {
// $("#adsense").hide();
// $("#custom").hide();
// }
});
</script>
<div class="form-group" id="custom">
<label for="ad_img_title" id="ad_img_title">Advertisement image</label>
<br>
<br>
<?php
if ($db_sidebar_ad_method == 'custom') {
?>
<img src="../ads/<?php echo $db_sidebar_ad_image ?>" alt="" width="200px">
<?php
}
?>
<input class="form-control" type="file" name="ad_image">
</div>
<div class="form-group" id="action">
<label for="ad_title">Ad action (link):</label>
<input value="<?php echo $db_sidebar_ad_action ?>" class="form-control" type="url" placeholder="Add http:// or https://" name="sidebar_ad_action" required>
</div>
<div class="form-group" id="adsense">
<label for="ad_title">Adsense code:</label>
<textarea name="sidebar_adsense_code" id="" cols="30" rows="5" class="form-control"><?php echo $db_sidebar_adsense_code ?></textarea>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" name="sidebar-ad-submit" value="Add Record">
</div>
</form>
<?php
if (isset($_POST['sidebar-ad-submit'])) {
$sidebar_rec_title = $_POST['sidebar_rec_title'];
$sidebar_ad_method = $_POST['sidebar_ad_method'];
if ($sidebar_ad_method == 'adsense') {
$sidebar_adsense_code = $_POST['sidebar_adsense_code'];
$sidebar_ad_image = 'none';
$sidebar_ad_action = 'none';
} elseif ($ad_method == 'custom') {
$sidebar_adsense_code = 'none';
$sidebar_ad_action = $_POST['sidebar_ad_action'];
$sidebar_ad_image = $_FILES['sidebar_ad_image']['name'];
$sidebar_ad_image_temp = $_FILES['sidebar_ad_image']['tmp_name'];
move_uploaded_file($sidebar_ad_image_temp, "../ads/$sidebar_ad_image");
if (empty($sidebar_ad_image)) {
$query = "SELECT * FROM sidebar_ad ";
$select_image = mysqli_query($connection, $query);
while ($row = mysqli_fetch_array($select_image)) {
$sidebar_ad_image = $row['ad_image'];
}
}
}
if ($sidebar_ad_method == 'adsense' and empty($sidebar_adsense_code)) {
echo '<script>alert("You have to enter the adsense code");</script>';
} elseif ($sidebar_ad_method == 'custom' and empty($sidebar_ad_image)) {
echo '<script>alert("Please choose an image");</script>';
} else {
$query = "UPDATE sidebar_ad SET rec_title='{$sidebar_rec_title}', ad_method='{$sidebar_ad_method}', ad_image='{$sidebar_ad_image}', ad_action='{$sidebar_ad_action}',adsense_code='{$sidebar_adsense_code}' ";
$create_ad_query = mysqli_query($connection, $query);
if ($create_ad_query) {
// header("Location: sidebar-ad.php");
}
}
}
?>
</div>
<div class="tab-pane container fade" id="home-top-ad">
<form action="" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="ad_title">Record Name:</label>
<input value="<?php echo $db_rec_title; ?>" class="form-control" type="text" name="ad_title" required>
</div>
<div class="form-group">
<label for="ad_title">Advertisement method</label>
<br>
<input value="adsense" type="radio" name="method" <?php if ($db_ad_method == 'adsense') {
echo 'checked';
} ?>>Adsense
<br>
<input value="custom" type="radio" name="method" <?php if ($db_ad_method == 'custom') {
echo 'checked';
} ?>>Custom
</div>
<script>
$("input[type='radio']").change(function() {
if ($(this).val() == "adsense") {
$("#adsense").show();
$("#custom").hide();
$("#action").hide();
} else if ($(this).val() == "custom") {
$("#custom").show();
$("#action").show();
$("#adsense").hide();
}
// else {
// $("#adsense").hide();
// $("#custom").hide();
// }
});
</script>
<div class="form-group" id="custom">
<label for="ad_img_title" id="ad_img_title">Advertisement image</label>
<br>
<br>
<?php
if ($db_ad_method == 'custom') {
?>
<img src="../ads/<?php echo $db_ad_image ?>" alt="" width="200px">
<?php
}
?>
<input class="form-control" type="file" name="ad_image">
</div>
<div class="form-group" id="action">
<label for="ad_title">Ad action (link):</label>
<input value="<?php echo $db_ad_action ?>" class="form-control" type="url" placeholder="Add http:// or https://" name="ad_action" required>
</div>
<div class="form-group" id="adsense">
<label for="ad_title">Adsense code:</label>
<textarea name="adsense_code" id="" cols="30" rows="5" class="form-control"></textarea>
</div>
<div class="form-group">
<input class="btn btn-primary" type="submit" name="top-ad-submit" value="Add Record">
</div>
</form>
<?php
if (isset($_POST['top-ad-submit'])) {
$rec_title = $_POST['ad_title'];
$ad_method = $_POST['method'];
if ($ad_method == 'adsense') {
$adsense_code = $_POST['adsense_code'];
$ad_image = 'none';
$ad_action = 'none';
} elseif ($ad_method == 'custom') {
$adsense_code = 'none';
$ad_action = $_POST['ad_action'];
$ad_image = $_FILES['ad_image']['name'];
$ad_image_temp = $_FILES['ad_image']['tmp_name'];
move_uploaded_file($ad_image_temp, "../ads/$ad_image");
if (empty($ad_image)) {
$query = "SELECT * FROM home_top_ad ";
$select_image = mysqli_query($connection, $query);
while ($row = mysqli_fetch_array($select_image)) {
$ad_image = $row['ad_image'];
}
}
}
if ($ad_method == 'adsense' and empty($adsense_code)) {
echo '<script>alert("You have to enter the adsense code");</script>';
} elseif ($ad_method == 'custom' and empty($ad_image)) {
echo '<script>alert("Please choose an image");</script>';
} else {
$query = "UPDATE home_top_ad SET rec_title='{$rec_title}', ad_method='{$ad_method}', ad_image='{$ad_image}', ad_action='{$ad_action}',adsense_code='{$adsense_code}' ";
$create_ad_query = mysqli_query($connection, $query);
if ($create_ad_query) {
// header("Location: home-top-ad.php");
}
}
}
?>
</div>
<div class="tab-pane container fade" id="home-bottom-ad">This is a setting tab using pill data-toggle attribute.</div>
</div>
</div>Editor is loading...