将值发布到另一页的问题

时间:2015-10-28 11:46:11

标签: php

我的行动页面..

if(isset($_POST['submit'])){
echo 'OK';
}

另一页..

<form methos="post" action="action.php">
<input type="text" name="value">
<input type="submit" name="submit" value="add">
</form>

这不起作用,但其工作为

(action="#")

并在另一页中包含操作。

5 个答案:

答案 0 :(得分:2)

你有拼写错误:

<强>替换

<form methos="post" action="action.php">

。通过

<form method="post" action="action.php">

是的。 :)

答案 1 :(得分:1)

  

将此git init更改为此methos="post"

并在method="post"页面中使用此

action.php

并在if(isset($_POST['submit'])){ $value = $_POST['value']; echo $value; }

index.php

编辑01

改进了<form method="post" action="action.php"> <input type="text" name="value"> <input type="submit" name="submit" value="add"> </form>

action.php

答案 2 :(得分:1)

的index.php

<html>
<head>        
</head>
<body>
<form method="post" action="#">
<input type="text" name="value">
<input type="submit" name="submit" value="submit">
</form>
</body>
</html>

action.php的

<?php
if(isset($_POST['submit'])){
echo 'OK';
}
?>

答案 3 :(得分:0)

我看到一个拼写错误

<form methos="post" action="action.php">
    <input type="text" name="value">
    <input type="submit" name="submit" value="add">
</form>

应该成为

<form method="post" action="action.php">
    <input type="text" name="value">
    <input type="submit" name="submit" value="add">
</form>

其余的代码应该没问题。

答案 4 :(得分:0)

我已尝试过这种情况,但只获得了其他输出

if(isset($_POST['submit'])){
$value = $_POST['value'];
echo $value;
}else {
echo 'Not Post.';
}

伙计我找到解决方案没有任何代码的问题,它由于(.htaccess)文件删除文件后所有代码都正常工作,我不知道为什么会发生这种情况但如果你能找到并且解决这个问题...

#Options +FollowSymLinks -MultiViews
# Turn mod_rewrite on
RewriteEngine On
RewriteBase /

# To externally redirect /dir/foo.php to /dir/foo
RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s([^.]+)\.php [NC]
RewriteRule ^ %1 [R,L,NC]

## To internally redirect /dir/foo to /dir/foo.php
RewriteCond %{REQUEST_FILENAME}.php -f [NC]
RewriteRule ^ %{REQUEST_URI}.php [L]

#error documment..
Options -Indexes
ErrorDocument 403 http://localhost/error/403