urlencoded = new URLSearchParams();
urlencoded.append("email", "bottle@gmail.com");
urlencoded.append("password", "bottleHook");
var requestOptions = {
method: 'POST',
headers: { "Content-Type": "application/x-www-form-urlencoded"},
body: urlencoded,
redirect: 'follow'
};
fetch("http://localhost/php-web/projects/urlShort/system/signup.php", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
how would I get data in php file ?
$_POST['email'] and $_POST['password'] ?
easy peasy lemon squeezy Thank you 😅🤗
wow man this is great suggestion before this I was working in a bit messy way was using xmlHttpRequest() stringfy users input and set it equal to request.send("x=" + stringfied Inputs) and in php was doing this stuff accessing x variable which contains all data of user now i don't need to do add header and json_encode and decode stuff header("Content-Type: application/json; charset=UTF-8"); // $obj = json_decode($_POST["x"], false); // echo json_encode($obj);
Обсуждают сегодня