Dealing with html forms

时间:2015-07-27 作者:amin gholami

I want to work with html form but i cant understand the Action method and when we need to use it.For example found this code on w3schools:

<form action="action_page.php">
First name:<br>
<input type="text" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</form>

how can we use \'lastname\' in other file?

3 个回复
最合适的回答,由SO网友:M.Mazraeshahi 整理而成

使用以下代码:

<form action="action_page.php" method="post">
First name:<br>
<input type="text" name="firstname" value="">
<br>
Last name:<br>
<input type="text" name="lastname" value="">
<br>
<input type="submit" value="Submit">
</form>
在文件“action\\u page.php”中使用以下代码:

$firstname = $_POST["firstname"];
$lastname = $_POST["lastname"];
您可以使用以下代码读取信息:

<pre>
    <?php 
    print_r($_POST);
؟>
</pre>

var_dump($_POST);

SO网友:user76056

你可以在action_page.php 使用$_POST[\'lastname\'].

SO网友:Hari Om Gupta

我想应该是$_REQUEST[\'lastname\']; 您可以检查如下:echo $_REQUEST[\'lastname\'];

结束