首页 > 解决方案 > 如何在php中提交表单中获取passport_mrz1值?

问题描述

我已经提交了带有 passport_mrz1 和 passport_mrz2 值的表格,如何获取 passport_mrz1 值?

header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title></title>
    </head>
    <body>
        <h1>Passport Input</h1>
        <form action="" method="post" accept-charset="UTF-8">
            <label>passport_mrz1:
                <input name="passport_mrz1" type="text" value="P<USAWILLIAMS<<JUSTIN<<<<<<<<<<<<<<<<<<<<<<<" /></label>
            <br/>
            <label>passport_mrz2
                <input name="passport_mrz2" type="text" value="99003853<1USA1101018M1207046110101111<<<<<94"/></label>
            </br>
            <input type="submit" value="submit this form" />
        </form>

    </body>
</html>

标签: php

解决方案


您可以使用POST方法将数据传递给PHP脚本。单击按钮时,我添加按钮名称clicked以执行发布条件。

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

   echo $_POST['passport_mrz1'];
 }

 ?>

HTML是:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
</head>
<body>
    <h1>Passport Input</h1>
    <form action="" method="post" accept-charset="UTF-8">
        <label>passport_mrz1:
            <input name="passport_mrz1" type="text" value="P" ><USAWILLIAMS<<JUSTIN<<<<<<<<<<<<<<<<<<<<<<<" /></label>
        <br/>
        <label>passport_mrz2
            <input name="passport_mrz2" type="text" value="99003853<1USA1101018M1207046110101111<<<<<94"/></label>
        </br>
        <input type="submit" value="submit this form" name="clicked" />
    </form>

</body>


推荐阅读