Mercurial > nebulaweb3
diff default/node_modules/jquery-tabledit/example.php @ 0:1d038bc9b3d2 default tip
Up:default
author | Liny <dev@neowd.com> |
---|---|
date | Sat, 31 May 2025 09:21:51 +0800 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/default/node_modules/jquery-tabledit/example.php Sat May 31 09:21:51 2025 +0800 @@ -0,0 +1,27 @@ +<?php + +// Basic example of PHP script to handle with jQuery-Tabledit plug-in. +// Note that is just an example. Should take precautions such as filtering the input data. + +header('Content-Type: application/json'); + +$input = filter_input_array(INPUT_POST); + +$mysqli = new mysqli('localhost', 'user', 'password', 'database'); + +if (mysqli_connect_errno()) { + echo json_encode(array('mysqli' => 'Failed to connect to MySQL: ' . mysqli_connect_error())); + exit; +} + +if ($input['action'] === 'edit') { + $mysqli->query("UPDATE users SET username='" . $input['username'] . "', email='" . $input['email'] . "', avatar='" . $input['avatar'] . "' WHERE id='" . $input['id'] . "'"); +} else if ($input['action'] === 'delete') { + $mysqli->query("UPDATE users SET deleted=1 WHERE id='" . $input['id'] . "'"); +} else if ($input['action'] === 'restore') { + $mysqli->query("UPDATE users SET deleted=0 WHERE id='" . $input['id'] . "'"); +} + +mysqli_close($mysqli); + +echo json_encode($input);