我试图检索使用POSTMAN发送的POST请求。我能够检索所有其他参数的值,但却无法获取电子邮件的值。我的代码有什么问题?
<?php
$app = new \Slim\App;
$app->post('/instituteRegister', function(Request $request , Response
$response){
$irno = $request->getParam('irno');
$iname = $request->getParam('iname');
$iaddress = $request->getParam('iaddress');
$state = $request->getParam('state');
$district = $request->getParam('district');
$ipno = $request->getParam('ipno');
$email = $request->getParam('email');
$password = $request->getParam('password');
//echo $code ."<br>";
echo $irno ." <= irno <br>";
echo $iname ." <= iname <br>";
echo $iaddress ." <= iaddress <br>";
echo $state ." <= state <br>";
echo $district . "<= district <br>";
echo $ipno ." <= ipno <br>";
echo $email . " <= email <br>";
echo $password . " <= password <br>";
);
使用邮递员我发送了邮件请求,如下图所示 OUTPUT
为什么电子邮件字段为空? POST:http://localhost/EOnlineService/api/v1/institution/institution.php/instituteRegister?irno=12&iname=grace&iaddress=xyz&state=kohima&district=xyz&ipno=12&email = grace@gmaill.com& password = hello123
答案 0 :(得分:0)
@
登录电子邮件可能有问题,网址会对电子邮件地址进行编码并检查输出。 grace%40gmail.com
我建议在post
请求中将此数据作为json原始实体传递,因为url的长度限制。
答案 1 :(得分:0)
$电子邮件=&#34; xyz@gmail.com" ;; $ encodedEmail =用urlencode($电子邮件);
$ decodingEmail = urldecode($ _ GET [&#39; email&#39;]); //它将xyz@gmail.com作为字符串返回,解码。