我有这个代码。尝试将表单值从一个内部页面传递到另一个内部页面,但不起作用。
代码如下:
<div data-role="page" id="home">
<div data-role="header">
<h1>Page One</h1>
</div><!-- /header -->
<div data-role="content">
<form action="post" name="myform">
<input type="text" value="" name="mytext" />
<input type="submit" value="submit" />
</form>
</div><!-- /content -->
</div><!-- /page -->//和第2页
<div data-role="page" id="page2">
<div data-role="header">
<h1>Page Two</h1>
</div><!-- /header -->
<div data-role="content">
<?php if (isset($_POST['mytext'])) {
// do something with $_POST['value']
echo 'it works'; } ?>
</div><!-- /content -->
</div><!-- /page -->它基本上不起作用了。没有错误,但也没有值。
发布于 2011-06-12 18:07:27
错误最有可能出现在这里:
<form action="post" name="myform">
<input type="text" value="" name="mytext" />
<input type="submit" value="submit" />
</form>action应该是表单的处理程序,可以是同一个页面,也可以是另一个页面(详细说明表单的php脚本所在的页面)。POST是方法。(可以是GET或POST)
所以它应该是:
<form action="" method="POST" name="myform"> <!-- action = "" reloads the same page, otherwise you could write action="myphppage.php" or whatever -->
<input type="text" value="" name="mytext" />
<input type="submit" value="submit" />
</form>发布于 2011-06-12 18:07:24
你的动作应该是处理post变量的php脚本,方法应该是post。
<form action="somefile.php" method="post">发布于 2011-06-12 18:07:28
<form action="post" name="myform">是错误的。
它应该是这样的:
<form method="post" name="myform" action="">你需要发送一个POST方法。该操作为空,因此它将其发送到页面本身。
https://stackoverflow.com/questions/6321379
复制相似问题