Rishabh Jain
Rishabh Jain

Reputation: 108

Track the POST request

i'm Wondering is there any way to track the incoming post requests in a form?

i have

<form method='post'>
<input type='text' name'test' />
<input type='submit' name'submit' />
</form>

and i want to allow only specific websites to access the form by curl request, is it possible to do so ?

// Edit ----------

1) I want to make a script that allow only curl request, but only from certain domains.

2) Use of Referer keys is not in option because they can leak out easily.

Upvotes: 0

Views: 939

Answers (1)

JimiDini
JimiDini

Reputation: 2069

As far as I understood, you look for an ability to limit requests to curl-callers located on specific servers. If that is the case, then you should just check that $_SERVER['REMOTE_ADDR'] is in a white-list.

<?php
$allowed_ips = ['127.0.0.1', '123.123.123.123'];  // put here the list of IPs
if (!in_array($_SERVER['REMOTE_ADDR'], $allowed_ips) {
    die();
}

Upvotes: 1

Related Questions