douyi8408 2017-02-07 15:55 采纳率: 0%
浏览 52
已采纳

PHP没有从上一页的表单中获得任何响应

I have the file "1.php" and the file "2.php" ...

In "1.php", there's a HTML form:

<form action="2.php" method="post">
  <div class="form-group">
    <label for="db_username">Field 1:</label>
    <input type="text" class="form-control" id="db_username">
  </div>
  <div class="form-group">
    <label for="db_password">Field 2:</label>
    <input type="password" class="form-control" id="db_password">
  </div>
  <div class="form-group">
    <label for="db_passphrase">Field 3:</label>
    <input type="text" class="form-control" id="db_passphrase">
  </div>
  <button type="submit" class="btn btn-default">Next</button>
</form>

While in "2.php", the action must be applied in PHP .. like that:

<?php
// Process of Step "1"
$db_username = $_POST['db_username'];
$db_password = $_POST['db_password'];
$db_passphrase = $_POST['db_passphrase'];

if( !isset($db_username) || !isset($db_password) || !isset($db_passphrase) ) {
    header("Location: 1.php?error=1");
    die();
}
?>

However .. the values of $_POST['db_username'], $_POST['db_password'] and $_POST['db_passphrase'] is empty...

  • 写回答

4条回答 默认 最新

  • dpicx06888 2017-02-07 15:59
    关注

    You need to use the name attribute to later access the $_POST data, as in:

    <input type="text" class="form-control" id="db_username" name="db_username">
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100