【问题标题】:Isset not working on submit buttonIsset 在提交按钮上不起作用
【发布时间】:2016-03-02 00:39:58
【问题描述】:

这是一个视图(一个状态的templateUrl),由于某种原因,isset 可以正常工作。我在代码的底部通过传入 if(isset($_POST["submit"])){do这个} 。但它并没有这样做。我清楚地给了它一个“提交”的名称属性和一个“提交”的类型属性。请帮忙谢谢:

    <?php
var_dump($_GET);
require_once('PhpConsole.phar');
require_once('connection.php');
  ?>
<!DOCTYPE html>
<html lang="en-US">
<head>
</head>

<body>

    <div id="page">

    <h1>Registration </h1>
    <form  method = "post">
          <input  type = "text" name = "username" placeholder = "Username"required/>
          <br>
          <input  type = "text"name = "email" placeholder = "Email"required/>
          <br>
          <input type = "text" placeholder = "password" name = "password" required/>
          <br>
          <input type = "submit" name = "submit"/>
    </form>
    </div>
<?php
$username = $_POST["username"];
$email = $_POST["email"];
$password = $_POST["password"];
if(isset($_POST["submit"])){

  $query = "INSERT INTO authe (authe.Email , authe.Password, authe.Username) VALUES ('".$email."', '".$password."' , '".$username."')";
  if($result = $connection->query($query))
  {
  header("Location: http://localhost:8012/phpForm/login.php");
  }
  else{
    echo "Something Went wrong...";
  }
}
 ?>

</body>
  </html>

【问题讨论】:

  • 空格是怎么回事? &lt;form method = "post"&gt;
  • 那没有帮助。更新@samayo 上面的代码
  • 是的,但遗憾的是,这对按钮没有帮助@RiggsFolly :(但感谢您指出这一点
  • 你有 2 个按钮?你确定你按对了吗???
  • 什么是&lt;md-whiteframe&gt; 它不是我认识的 HTML 标签

标签: javascript php html angularjs


【解决方案1】:

当我测试时,这个简单的 PHP 代码可以工作,

<!DOCTYPE html>
<html lang="en-US">
    <head>
    </head>
    <body>
        <div id="page">
            <h1>
                Registration 
            </h1>
            <form  method = "post">
                <input  type = "text" name = "username" placeholder = "Username"required/>
                <br>
                <input  type = "text"name = "email" placeholder = "Email"required/>
                <br>
                <input type = "text" placeholder = "password" name = "password" required/>
                <br>
                <input type = "submit" name = "submit"/>
            </form>
        </div>
        <?php
            print_r($_POST); 
            if(isset($_POST["username"])){
                $username = $_POST["username"];
            }
            if(isset($_POST["email"])){
                $email = $_POST["email"];
            }
            if(isset($_POST["password"])){
                $password = $_POST["password"];
            }
            if(isset($_POST["submit"])){
                    echo $username .PHP_EOL;
                    echo $email .PHP_EOL;
                    echo $password .PHP_EOL;
            }
        ?>
    </body>
</html>

现在应其他人的要求,请发布带有 Angular 组件的非工作代码以提供进一步帮助。

【讨论】:

    猜你喜欢
    • 2013-04-09
    • 1970-01-01
    • 1970-01-01
    • 2017-03-13
    • 2015-03-27
    • 2016-09-11
    相关资源
    最近更新 更多