Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class database{
- private $connection,
- $HOST = 'localhost',
- $USERNAME = 'root',
- $PASSWORD = '',
- $DBNAME = 'bm-massage',
- $query = null;
- public function __construct(){
- $this->connection = new mysqli($this->HOST,$this->USERNAME,$this->PASSWORD,$this->DBNAME) or die('failed to connect');
- }
- public function update_massage_place($name,$capacity,$address,$id){
- $this->query = "UPDATE massage_places SET MassagePlaceName = ?, Capacity = ?, MassagePlaceAddress = ? WHERE MassagePlaceID = ?";
- $statement = $this->connection->prepare($this->query);
- $statement->bind_param('sisi',$name,$capacity,$address,$id);
- $statement->execute();
- }
- }
- <?php
- class input{
- public static function get($name){
- if(isset($_POST[$name])){
- return $_POST[$name];
- }else if(isset($_GET[$name])){
- return $_GET[$name];
- }else{
- return false;
- }
- }
- }
- ?>
- <?php
- require_once 'core/init.php';
- require_once 'templates/header.php';
- $id = input::get('id');
- ?>
- <link rel="stylesheet" type="text/css" href="styles/view-place-detail-style.css">
- <title>View Place Detail</title>
- <script type="text/javascript">
- $(document).ready(function(){
- $('#update-massage-place-form').submit(function(event){
- event.preventDefault();
- var name = $('#name').val();
- var capacity = $('#capacity').val();
- var address = $('#address').val();
- $('.error-massage').load('view-place-detail-validation.php?id=<?php $id?>',{
- name : name,
- capacity : capacity,
- address : address,
- });
- });
- });
- </script>
- <div class="container" style="margin-left: 0">
- <?php echo $db->get_massage_place_name_admin($id) ?>
- <form id="update-massage-place-form" autocomplete="off" method="POST">
- <label>Massage Place Name</label> <br>
- <input id='name' type="text" name="update-place-name" value="<?php echo $db->get_massage_place_name_admin_textinput($id) ?>"><br>
- <label>Capacity (per day)</label><br>
- <input id='capacity' type="text" name="update-place-capacity" value='<?php echo $db->get_massage_place_capacity_admin($id) ?>'><br>
- <label>Address</label><br>
- <input id='address' type="text" name="update-address" value=" <?php echo $db->get_massage_place_address_admin($id) ?>"><br><br>
- <button type="submit">Update</button>
- <div class="error-massage">
- </div>
- </form>
- </div>
- <?php
- require_once 'core/init.php';
- $name = input::get('name');
- $address = input::get('address');
- $capacity = input::get('capacity');
- $id = input::get('id');
- if(empty($name)) echo "Massage place name must be filled!";
- else if (empty($address)) echo "Massage place address must be filled!";
- else if (empty($capacity)) echo "Capacity must be filled!";
- else if (!is_numeric($capacity)) echo "Capacity must be number!";
- else{
- $db->update_massage_place($name,$capacity,$address,$id);
- echo '<script>alert("Update massage place success!")
- window.location.href = "home.php?update_success";
- ';
- }
- ?>
Add Comment
Please, Sign In to add comment