Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/277.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 表单未提交/正在工作_Php_Jquery_Html_Forms - Fatal编程技术网

Php 表单未提交/正在工作

Php 表单未提交/正在工作,php,jquery,html,forms,Php,Jquery,Html,Forms,此表单提交不起作用,有人能帮我吗 我正在使用引导css,并试图提交一个简单的表单,有一个小问题,但我无法检测到问题,请帮助 用户名 密码 记得我吗 登录 用于表单处理的PHP代码 if (isset($_POST['unm'])) { if ($_POST['unm']=="admin" && $_POST['pwd']=="xxxxxx") { echo '<script type="text/javascript">alert("Hi Admin");

此表单提交不起作用,有人能帮我吗

我正在使用引导css,并试图提交一个简单的表单,有一个小问题,但我无法检测到问题,请帮助


用户名
密码
记得我吗
登录
用于表单处理的PHP代码

if (isset($_POST['unm'])) {
if ($_POST['unm']=="admin" && $_POST['pwd']=="xxxxxx") {
    echo '<script type="text/javascript">alert("Hi Admin");</script>';
    header('Location: home.php');
}
else{
    echo '<script type="text/javascript">alert("Unknown Username/Bad password");</script>';
}
if(isset($\u POST['unm'])){
如果($_POST['unm']==“admin”&&$_POST['pwd']==“xxxxxx”){
回显“警报”(“Hi Admin”);
标题('Location:home.php');
}
否则{
回显“警报(“未知用户名/错误密码”);
}

}

如果此表单的php位于同一页面上,则将操作指向同一页面是有意义的。通过这种方式,表单将被发送到页面的刷新版本,PHP将从那里获取并处理表单

因此,如果表单位于名为form.php的页面上

那就应该是

<form id="logfrm" action="form.php" method="post" class="form-horizontal">


您可以使用Firebug监视$_POST['umn'],以查看所有内容都已正确发送

您刚刚错过了操作url,因此表单提交无法正常工作。。。我只是将表单action标记从action=”“更改为action=“action.php”其中action.php是包含处理html表单的php代码的文件。使用下面的代码可以解决您的问题

home.php

    <?php
    if(isset($_POST['submit_button']))
    {

if ($_POST['unm']=="admin" && $_POST['pwd']=="xxxxxx") {
    echo '<script type="text/javascript">alert("Ok");</script>';
    header('Location:home.php');
}
else{
    echo '<script type="text/javascript">alert("Unknown Username/Bad password"); if(confirm("Unknown Username/Bad password")){document.location.reload(true);}</script>';

}
}

else
{

?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body><br/><br/><br/><br/>
    <div class="container">
    <div class="thumbs askus container col-md-6 col-md-offset-4">
        <form id="logfrm"  method="post" class="form-horizontal" action="home.php">
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">Username</label>
            <div class="col-sm-4">
              <input type="text" name="unm" class="form-control" id="inputUser" placeholder="Username">
            </div>
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
            <div class="col-sm-4">
              <input type="password" name="pwd" class="form-control" id="inputPassword" placeholder="Password">
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-2 col-sm-4">
              <div class="checkbox">
                <label>
                  <input type="checkbox"> Remember me
                </label>
              </div>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-2 col-sm-4">
              <button type="submit" class="btn btn-default" name="submit_button" >Sign in</button>
            </div>
          </div>
        </form>
    </div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
  <?php } ?>
</html>

引导101模板





用户名 密码 记得我吗 登录
什么不起作用?表单标记中的“操作”字段为空。把你的PHP脚本地址放在那里。action=“”同一页?@ojovirtual如果它是空的,那么他希望它加载到同一页是的,PHP脚本在同一页上我已经尝试过了,页面未导航到d提交上的其他页面php在页面上的顺序很重要-当表单重新提交到同一页面时,它将从页面顶部向下运行脚本,因此可能是php在页面上的定位问题-php在同一页面上的位置在哪里?我正在将d表单提交到同一页面问题已解决。。。不管怎么说,我没有真正的麻烦制造原因solved@SarathMohan请评论你的实际问题?我认为对于上述问题,这应该是解决办法。
    <?php
    if(isset($_POST['submit_button']))
    {

if ($_POST['unm']=="admin" && $_POST['pwd']=="xxxxxx") {
    echo '<script type="text/javascript">alert("Ok");</script>';
    header('Location:home.php');
}
else{
    echo '<script type="text/javascript">alert("Unknown Username/Bad password"); if(confirm("Unknown Username/Bad password")){document.location.reload(true);}</script>';

}
}

else
{

?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Bootstrap 101 Template</title>

    <!-- Bootstrap -->
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
</head>
<body><br/><br/><br/><br/>
    <div class="container">
    <div class="thumbs askus container col-md-6 col-md-offset-4">
        <form id="logfrm"  method="post" class="form-horizontal" action="home.php">
          <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">Username</label>
            <div class="col-sm-4">
              <input type="text" name="unm" class="form-control" id="inputUser" placeholder="Username">
            </div>
          </div>
          <div class="form-group">
            <label for="inputPassword3" class="col-sm-2 control-label">Password</label>
            <div class="col-sm-4">
              <input type="password" name="pwd" class="form-control" id="inputPassword" placeholder="Password">
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-2 col-sm-4">
              <div class="checkbox">
                <label>
                  <input type="checkbox"> Remember me
                </label>
              </div>
            </div>
          </div>
          <div class="form-group">
            <div class="col-sm-offset-2 col-sm-4">
              <button type="submit" class="btn btn-default" name="submit_button" >Sign in</button>
            </div>
          </div>
        </form>
    </div>
</div>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="js/bootstrap.min.js"></script>
  </body>
  <?php } ?>
</html>