我正在尝试从邮递员到服务器发帖子。一切似乎都没问题,但当我尝试发帖时,它会返回错误,如图所示
<th align='left' bgcolor='#f57900' colspan="5">
<span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Notice: Undefined index: name in Upload-Download-PDF-File-Demo\upload.php on line
<i>27</i>
</th>
这是php文件的片段
$response = array();
if($_SERVER['REQUEST_METHOD']=='POST'){
//checking the required parameters from the request
//connecting to the database
//$con = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME) or die('Unable to Connect...');
$con = mysqli_connect(HOST,USER,PASS,DB) or die('Unable to Connect...');
//getting name from the request
$name = $_POST['name'];
Here is a picture on my attempt from postman
这是我第一次遇到这种类型的错误。请问有什么不对
答案 0 :(得分:0)
在Postman中切换到x-www-form-urlencoded以模仿HTML表单
答案 1 :(得分:-1)
这意味着您没有名为&#34; name&#34;的POSTed值。可能是由于错误的表格编码。