S
S
senseisammy2021-07-02 21:52:03
PHP
senseisammy, 2021-07-02 21:52:03

How to submit a json contact form to an external resource?

there is an html application form

<form method="POST">
        <div class="title">
          <i class="fas fa-pencil-alt"></i> 
          <h2>example</h2>
        </div>
        <div class="info">
      <input type="text" name="hash" placeholder="">
          <input type="text" name="fio" placeholder="ФИО">
          <input type="text" name="email" placeholder="Электронная почта">
          <input type="number" name="phone" placeholder="+7(7__) ___ __ __" class="rfield" />
          <input type="number" name="iin" placeholder="ИИН">
          <input type="number" name="loan_amount" placeholder="Сумма кредита">
        </div>
    <button onclick="sendJSON()">Отправить</button>
    <p class="result" style="color:blue"></p>
      </form>


and there is an api connection instruction Connection

instruction:
HTTP request
Method POST
URL: https://example.com

Headers:
Authorization Basic 63646643thrtrgd3ff135f502120992
content-type application/json

Request body:
{
"hash":"****** "
"fio":"test",
"phone":"+777777777",
"email":"[email protected]",
"iin":"123123123123",
"loan_amount": '200000',
"towns": "2",
} it is

necessary that a person can send data from the form in this way, does anyone have a ready-made solution?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Edward, 2021-07-03
@Drayde

https://snipp.ru/php/curl

R
rPman, 2021-07-03
@rPman

The instructions should have told you how the hash field is formed in the request body (including the order of the fields), most likely you are given some kind of secret key, with the help of which this is done according to some crypto-resistant algorithm. We can only guess here, if this is HTTP Authorization Basic, then you must have a
login and password, all the main libraries support this authorization, everyone uses curl in php, the first example from Google
client, the secret login/password (or key) will become available to all users. Those. a request must be sent from the client in your format, and the server already forms the correct one, receives a response and returns it to the client.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question