我正在尝试在论坛中实现创建主题部分
为什么我不能使用另一个php文件,说b.p p来获取从a.p p发送的数据?
$topic=$_POST['title'];
$detail=$_POST['content'];
$name=$_POST['username'];
错误提示在这3个输入处未定义索引
因为您调用这个脚本时没有发送POST
数据。
按以下方式使用:
$topic = empty($_POST['title']) ? null : $_POST['title'];
$detail = empty($_POST['detail']) ? null : $_POST['detail'];
$name = empty($_POST['name']) ? null : $_POST['name'];
它将避免错误,如果你只是请求脚本没有POST
,变量将包含空值