DELETE method and 000webhost banner


#1

Hi,
First of all thanks for the great hosting, i have 2 questions:
DELETE METHOD I have a delete method in my application, that works perfectly in localhost but when i send to 000webhost isnt working, all my other methods GET and POST works.

000webhost banner How can I turn off? I turned off few days ago but now i can’t, need to be premium?


#2

Please consider reading this topic


#3

Hi my friend.
So i have a registrar registro.br and because of that i cant turn it off?
Even if i pay for host only ?
Maybe i can pay for host and new domain only .com and change my .com.br redirects to .com ?!

[quote=“mariante, post:1, topic:81068”]
DELETE METHOD I have a delete method in my application, that works perfectly in localhost but when i send to 000webhost isnt working, all my other methods GET and POST works.
[/quote]?


#4

You have 2 ways to disable that banner:


#5

Ok, so consider that i bought, now i have mywebsite.com (hostinger) and mywebsite.com.br (registrar), so like that i can turn it off right?
And what about my other question? DELETE method only if I go premium too?


#6

I think that should be the case.

Have you checked the correct paths?
Also, what do you get hen executing?


#7

Ok, i’m going to look in buy new domain.

Yes, in localhost works like a charm, the paths are correctly for local and 000webhost,
Errors:
status code 0,
Lt ,
headers: mt
:disappointed_relieved: i’ve never seen.

My php already have:

header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE');

Print:


#8

You want to delete a value from the database?
Or delete a file?


#9

Delete a value where user = user and cod = 12345
In my localhost works like a charm, in here 000webhost only all my others things that uses my api or dash_api works, methods get and post works perfectly,


#10

Hi @mariante
How do you use delete method? With an ajax request? Or in any other way?


#11

In localhost works.
app:

delCod (delcod) {
        if (delcod) {
          this.delcod = delcod
          ///LOCALHOST this.$http.delete('http://localhost/dash_api/?user=' + this.login.user + '&pass=&cod=' + this.delcod)
          this.$http.delete('/src/dash_api/?user=' + this.login.user + '&pass=&cod=' + this.delcod)
          .then(function (response) {
            if (response.status === 200) {
              this.getCodsFromApi()
              .then(data => {
                console.log(data.items)
                this.items = data.items
                this.totalItems = data.total
              })

              this.snackbar = true
              this.snackText = 'Código deletado com sucesso!'
              this.context = 'success'
              this.delcod = ''
              this.dialogCod = false
            } else {
              this.snackbar = true
              this.snackText = 'Falha ao deletar Código!'
              this.context = 'error'
              this.delcod = ''
              this.dialogCod = false
            }
          })
          .catch(function (error) {
            console.log(error)
          })
        } else {
          this.snackbar = true
          this.snackText = 'Falha ao deletar Código!'
          this.context = 'error'
          this.delcod = ''
          this.dialogCod = false
        }
      }

api:

elseif ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
  $codigo = $_REQUEST['cod'];
  $user = $_REQUEST['user'];

  $queryDel = $db->prepare("DELETE FROM codigos WHERE user = :user AND cod = :codigo");
  $queryDel->execute(['user' => $user, 'codigo' => strtolower($codigo)]);

  if ($queryDel->rowCount() > 0) {
    $json['status'] = 'fail';
  } else {
    $json['status'] = 'ok';
  }
}

#12

Hi @mariante!

  1. Please lower your PHP version: 000webhost cPanel > Settings > General > Change PHP version > 5.6

  2. Please append the following code to a new line in /public_html/.htaccess

php_value outputbuffering on
  1. Please check and make sure there are no empty spaces/lines before php <?php / ?> tags.

Also, append the following code to .htaccess as well:

Header set Access-Control-Allow-Origin "*"
Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
Header set Access-Control-Allow-Methods "GET, POST, PUT, DELETE"

#13

All done, nothing changes :disappointed:


#14

I have just asked and operator.

000webhost does not allow any other HTTP method except GET, POST and HEAD. Anything else returns code 444 and is not supported.


Other HTTP methods are allowed only on paid plans:


#15

Hi @mariante

I suggest using simple GET or POST method to this.

If you use GET method send a parameter (delete=1)
And then use
elseif ($_REQUEST['DELETE'] === true) AS the conditional

It’s simple and the main reason is
according to w3 delete method is not used to delete something from database it is to delete a resource


#16

Ok, so if i buy, i can execute delete?
@Supun how can i delete something without delete?


#17

Ok, so if i buy, i can execute delete?

Yes.


#18

“without delete” means DELETE method?

If you need to delete that with DELETE method you can not do that here.
else use get method.


If you need a explanation please tell me.