| Server IP : 13.126.101.145 / Your IP : 216.73.216.182 Web Server : Apache/2.4.52 (Ubuntu) System : Linux ip-11-115-0-196 6.8.0-1039-aws #41~22.04.1-Ubuntu SMP Thu Sep 11 10:54:48 UTC 2025 x86_64 User : www-data ( 33) PHP Version : 8.3.17 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/html/rentals_updated/wp-content/plugins/equipments/ |
Upload File : |
<?php
function equipments_update() {
global $wpdb;
$table_name = "wp_equipments";
$id = $_GET["id"];
$name = $_POST["name"] ?? '';
//update
if (isset($_POST['update'])) {
$wpdb->update(
$table_name, //table
array('name' => $name), //data
array('ID' => $id), //where
array('%s'), //data format
array('%s') //where format
);
header('Location: admin.php?page=equipments_list&editmsg=succ');
}
//delete
else if (isset($_POST['delete'])) {
$wpdb->query($wpdb->prepare("DELETE FROM $table_name WHERE id = %s", $id));
} else {//selecting value to update
$equipments = $wpdb->get_results($wpdb->prepare("SELECT id,name from $table_name where id=%s", $id));
foreach ($equipments as $s) {
$name = $s->name;
}
}
?>
<div class="wrap">
<h2>Equipments</h2>
<?php if (isset($_POST['delete'])) { ?>
<div class="updated"><p>Equipments deleted</p></div>
<a href="<?php echo admin_url('admin.php?page=equipments_list') ?>">« Back to equipments list</a>
<?php } else if (isset($_POST['update'])) { ?>
<div class="updated"><p>Equipments updated</p></div>
<a href="<?php echo admin_url('admin.php?page=equipments_list') ?>">« Back to equipments list</a>
<?php } else { ?>
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']; ?>">
<p>Equipment Update Page</p>
<p class="form-row form-row-last validate-required" id="billing_last_name_field" data-priority="20">
<label for="billing_last_name" class="">Equipment Name</label>
<span class="woocommerce-input-wrapper">
<input type="text" class="input-text " name="name" id="name" value="<?php echo $name;?>" required>
</span>
</p>
<input type='submit' name="update" value='Save' class='button'>
</form>
<?php } ?>
</div>
<?php
}