Use PHP Variable inside PHP string
Solution:
Try:
CURLOPT_POSTFIELDS =>'{"username_or_email": "'.$user_name.'","password": "Freelance12"}'
I dont know why you try to concat the main string with Freelance12; Freelance12 is a string, you can write directly.
Answer
Solution:
I think this would probably be the approach I would recommend. Your POSTFIELDS looks like JSON so I would let PHP do the heavy lifting of turning it into a valid JSON object.
CURLOPT_POSTFIELDS => json_encode([
'username_or_email' => $user_name,
'password' => $pass
])
All this does is create an associative array and then JSON encode it with the aptly named json_encode()
function.
Were you to print the JSON string that is returned from this json_encode()
call it would be...
'{"username_or_email": "abc", "password": "12345"}'
Source