So I'm having doubts here, would it be possible to make the input fields I have play what I typed in a JSON?
EX: This would be the form
<form role="form" method="post" id="searches" accept-charset="utf-8" action="<?php bloginfo('template_url');?>/form.php" novalidate >
<label class="input-da-serach-1" for="de">De <input type="text" id="de" name="de" placeholder="Cidade:" required ></label>
<label class="input-da-serach-1" for="searches=[to_airports]">Para <input type="text" id="searches=[to_airports]" name="searches=[to_airports]" placeholder="Cidade:" required ></label>
<label class="input-da-serach-2" for="date_go">Ida <input type="date" name="go_date" min_days="1" max_days="365" required></label>
<label class="input-da-serach-2" for="data_back">Volta (opcional)<input type="date" name="search[back_date]" min_days="1" max_days="365" ></label>
<label class="input-da-serach-2">Passageiros <input type="text" name="" placeholder="01" ></label>
<button type="submit" id="searchsubmit" value="Procurar">Procurar</button>
</form>
he would have to get the values typed in - > (de) - > (to)
and playing in JSON
class MCrypt
{
private $key;
public function __construct($token) {
$this->key = $token;
}
function crypt($message, $url_encode = true) {
$iv = mcrypt_create_iv(16, MCRYPT_RAND);
$encrypted = mcrypt_encrypt(MCRYPT_RIJNDAEL_128, $this->key, $message, MCRYPT_MODE_CBC, $iv);
$encrypted = base64_encode($encrypted) .'|'. base64_encode($iv);
if ($url_encode) return urlencode($encrypted);
else return $encrypted;
}
function encrypt($message, $url_encode = true) {
return $this->crypt($message, $url_encode);
}
function decrypt($encrypted_message, $url_decode = true) {
if ($url_decode) $tokens = urldecode(trim($encrypted_message));
else $tokens = trim($encrypted_message);
$tokens = explode('|', $tokens);
if (count($tokens) == 2) {
$crypt = base64_decode($tokens[0]);
$iv = base64_decode($tokens[1]);
$decrypted = mcrypt_decrypt(MCRYPT_RIJNDAEL_128, $this->key, $crypt, MCRYPT_MODE_CBC, $iv);
echo preg_replace('[x00-x1Fx80-xFF]', '', $decrypted);
}
else return false;
}
}
$url = "******";
$crypt = new MCrypt('*********');
$encrypted_data = $crypt->encrypt('
{"searches":
["amigo", "multiplus", "tudo_azul"],
"type":"award_flight_money_tax",
"includes":"none",
"from_airports":"**jogar o valor do de aqui**",
"to_airports":"**jogar o valor do para aqui**",
"go_date":"2018-03-22",
"go_date_flexibility":"0",
"back_date":"2018-03-28",
"back_date_flexibility":"0",
"adults":"1",
"children":"0",
"babies":"0",
"cabin":"E"
}');
?>
urls: <?php
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, $url);
//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS,"data={$encrypted_data}");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($curl);
curl_close($curl);
echo ($output);
?>
The place is in bold that should take the value of the input and play in the indicated place, thank you already.
I have tried many things but always the error, and I am being forced to use this method without changing this area.
{"searches":
["amigo", "multiplus", "tudo_azul"],
"type":"award_flight_money_tax",
"includes":"none",
"from_airports":"**jogar o valor do de aqui**",
"to_airports":"**jogar o valor do para aqui**",
"go_date":"2018-03-22",
"go_date_flexibility":"0",
"back_date":"2018-03-28",
"back_date_flexibility":"0",
"adults":"1",
"children":"0",
"babies":"0",
"cabin":"E"
}');