Bootstrap模式中的表单不将PHP值发布到另一个页面(Form in Bootstrap modal not posting PHP values to another page)

编程入门 行业动态 更新时间:2024-10-27 11:26:20
Bootstrap模式中的表单不将PHP值发布到另一个页面(Form in Bootstrap modal not posting PHP values to another page)

我在引导模式窗口中使用表单将数据发布到另一个页面。 但是,当我尝试在另一页上打印帖子值时,我得到的是一个空数组。

这是我的模态代码:

<div class="modal hide" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> X</button> <h3 id="myModalLabel"> Enter your Credentials</h3> </div> <div class="modal-body"> <form id="modal-form" class="form-horizontal" accept-charset="UTF-8" method="POST" action="login.php" data-remote="true"> <div class="control-group"> <label class="control-label" for="inputEmail">Email</label> <div class="controls"> <input type="email" id="email" placeholder="Email"> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <input type="password" id="passwd" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <label class="checkbox"> <input type="checkbox"> Remember me </label> <input type="submit" class="btn btn-primary" value="Submit"/> <a href="register" class="btn btn-primary">Sign up</a> </div> </div> </form> </div> </div>

这是我在login.php中给出的命令:

echo "Email is:"; echo $_POST["email"]; echo "Password is:"; echo $_POST["passwd"];

但是我得到的只是一个空数组。

有什么特别的方式我应该这样做吗?

I am using a form in a bootstrap modal window to post data to another page. However when i try to print the post values on the other page all I am getting is an empty array.

Here's my modal code:

<div class="modal hide" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> X</button> <h3 id="myModalLabel"> Enter your Credentials</h3> </div> <div class="modal-body"> <form id="modal-form" class="form-horizontal" accept-charset="UTF-8" method="POST" action="login.php" data-remote="true"> <div class="control-group"> <label class="control-label" for="inputEmail">Email</label> <div class="controls"> <input type="email" id="email" placeholder="Email"> </div> </div> <div class="control-group"> <label class="control-label" for="inputPassword">Password</label> <div class="controls"> <input type="password" id="passwd" placeholder="Password"> </div> </div> <div class="control-group"> <div class="controls"> <label class="checkbox"> <input type="checkbox"> Remember me </label> <input type="submit" class="btn btn-primary" value="Submit"/> <a href="register" class="btn btn-primary">Sign up</a> </div> </div> </form> </div> </div>

Here's the command I'm giving in login.php:

echo "Email is:"; echo $_POST["email"]; echo "Password is:"; echo $_POST["passwd"];

However all I'm getting is an empty array.

Is there some sort of special way I'm supposed to do this?

最满意答案

您没有在输入中定义名称只需从代码中更改两行。 添加该输入的名称。

<input type="email" id="email" name="email" placeholder="Email" /> <input type="password" id="passwd" name="passwd" placeholder="Password" />

You have't define name in input just change two line from your code. add name of that input.

<input type="email" id="email" name="email" placeholder="Email" /> <input type="password" id="passwd" name="passwd" placeholder="Password" />

更多推荐

class,<div,id,电脑培训,计算机培训,IT培训"/> <meta name="description&

本文发布于:2023-08-06 22:19:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1457606.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:表单   不将   模式   页面   PHP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!