【问题标题】:POST method returning empty, it has name and idPOST 方法返回空,它有名称和 id
【发布时间】:2017-09-26 01:14:59
【问题描述】:

我正在做一个登录 PHP 代码,但是 post 方法返回的是空字符串。

这是我的 HTML:

  <form  action="iniSesion.php" method="post" >
    <div class="form-group">
      <input type="email" name="email_" 
         class="form-control" id="email" placeholder="Email">
    </div>
    <div class="form-group">
      <input type="password" name="password_" 
         class="form-control" id="password" placeholder="Password">
    </div>
    <button type="submit" class="btn btn-primary">Ingresar</button>
 </form>

这是我的 php

<?php

include_once('../_includes/dbconnect.php');
$conexion  = Conexion::conectar();

$email = mysqli_real_escape_string($conexion,$_POST["email_"]);
$password = mysqli_real_escape_string($conexion,$_POST["password_"]);


print_r($_POST);
echo $_POST["email_"];
echo $_POST["password_"];

Conexion::desconectar($conexion);
?>

但是所有的回声都是空的,我做错了什么?

提前致谢

--------编辑

我发现问题出在 mysqli_real_escape_string 函数上,但我想使用它,但我不知道为什么它使我的 POST 变量为空

【问题讨论】:

  • print_r($_POST) 的输出是什么?
  • 你确定echos 是空的而不是没有执行吗?您的错误日志是否报告了什么?您确定正在调用脚本本身吗?
  • 它是数组 ( ) @Nima
  • @KenY-N 是的,它们是空的,因为我还连接了字符串并且它们正在工作,但是当它是变量时,它是空的。比如: echo 'SELECT * FROM usuario u WHERE u.usu_usuario="' .$_POST["email_"] . '" 和 u.usu_password="'.$_POST["password_"].'"';
  • 您确定它在发布数据之前 没有失败吗?

标签: php html post


【解决方案1】:
mysqli_real_escape_string()

^ 这需要主动连接到数据库才能使用。

此代码必须在mysqli_real_escape_string() 之前:

$DatabaseConnection = mysqli_connect

【讨论】:

    猜你喜欢
    • 2019-01-18
    • 1970-01-01
    • 1970-01-01
    • 2015-02-03
    • 2013-05-19
    • 2018-11-18
    • 1970-01-01
    • 2018-02-18
    • 1970-01-01
    相关资源
    最近更新 更多