在输入框中获取url值

use*_*271 0 javascript php

在我的html页面中,我有这样的链接

<table width="100%" border="0" cellspacing="4" cellpadding="4">
          <tr>
            <td><a href="ApplicationRegister.php?plan=trial"><img src="images/box4.png" width="230" height="300" /></a></td>
            <td><a href="ApplicationRegister.php?plan=plan1"><img src="images/box1.png" width="230" height="300" /></a></td>
            <td><a href="ApplicationRegister.php?plan=plan2"><img src="images/box2.png" width="230" height="300" /></a></td>
            <td><a href="ApplicationRegister.php?plan=plan3"><img src="images/box3.png" width="230" height="300" /></a></td>
          </tr>
        </table>
Run Code Online (Sandbox Code Playgroud)

当我点击任何一个图像时,它将转到带有plan =相应值的ApplicationRegister.php页面.

在我的ApplicationRegister.php中,我有一个注册表

<form action="emailconfirmation.php" method="post" name="form1" id="form1"  onsubmit="return Validate();">
    Company Name: 
        <input type="text" name="CompanyName" style="width:230px; height:20px;" /><br /><br />
    Company E-mail : 
    <input type="text" name="Companyemail" style="width:230px; height:20px;" /><br /><br />
     Company Contact <input type="text" name="CompanyContact" style="width:230px; height:20px;" /><br /><br />
     Company Address: <input type="text" name="CompanyAddress" style="width:230px; height:20px;" /><br /><br />
     <input type="hidden" name="form_submitted" value="1"/> 
     <input type="submit" value="REGISTER" name="submit" />
                    </form>
Run Code Online (Sandbox Code Playgroud)

在这个页面中,它应该从url中获取值,例如plan = trail或plan1 ......无论url在哪里.然后提交所有值时应与这些表格数据一起提交.

怎么做到这一点?请帮忙.

Eri*_*ric 5

首先,您需要清理计划输入:

<?php
    $plan = @$_GET['plan'];
    $plan = +$plan; #convert to number
?>
Run Code Online (Sandbox Code Playgroud)

只需添加包含该值的另一​​个隐藏字段

<form action="emailconfirmation.php" method="post" name="form1" id="form1" onsubmit="return Validate();">
    ...
    <input type="submit" value="REGISTER" name="submit" />
    <input type="hidden" name="plan" value="<?php echo $plan ?>"/> 
</form>
Run Code Online (Sandbox Code Playgroud)

另一种选择是将它作为get参数添加到action:

<form action="emailconfirmation.php?plan=<?php echo $plan ?>"
      method="post" name="form1" id="form1" onsubmit="return Validate();">
    ...
    <input type="submit" value="REGISTER" name="submit" />
</form>
Run Code Online (Sandbox Code Playgroud)