Php 在输入框中获取url值
在我的html页面中,我有如下链接Php 在输入框中获取url值,php,javascript,Php,Javascript,在我的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&g
<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>
当我单击任何一个图像时,它将进入ApplicationRegister.php页面,并显示对应的plan=值
在我的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>
公司名称:
公司电邮:
公司联系人
公司地址:
在这个页面中,它应该从url中获取值,比如plan=trail或plan1。。。不管url中有什么。然后,在提交时,所有值都应与这些表单数据一起提交
如何做到这一点?请提供帮助。首先,您需要清理计划输入:
<?php
$plan = @$_GET['plan'];
$plan = +$plan; #convert to number
?>
首先,您需要清理计划输入:
<?php
$plan = @$_GET['plan'];
$plan = +$plan; #convert to number
?>
嘿,如果你将一个值作为URL的一部分发送,那么你应该有一个容器来获取它。使用php$\u GET[]获取该值。用谷歌搜索一下php表单将对你有所帮助,而不是给你代码
阅读此链接并继续编码 嘿,如果你要将一个值作为URL的一部分发送,那么你应该有一个容器来获取它。使用php$\u GET[]获取该值。通过谷歌搜索一下php表单将对你有所帮助,而不是提供代码
阅读此链接并继续编码 您需要在ApplicationRegister.php上的表单中添加一个隐藏字段,其中包含“plan”查询参数。表单中应包含以下HTML:
<input type="hidden" name="plan" value="<?php echo isset($_GET['plan']) ? $_GET['plan'] : 'trial'; ?>" />
您需要在ApplicationRegister.php上的表单中添加一个隐藏字段,其中包含“plan”查询参数。表单中应包含以下HTML:
<input type="hidden" name="plan" value="<?php echo isset($_GET['plan']) ? $_GET['plan'] : 'trial'; ?>" />
Downvoted,除此之外,您需要确保“plan”中的值是允许的值(例如,plan1到'4中的一个),然后使用
htmlspecialchars()
对其进行转义以减轻XSSDownvoted的影响,除此之外,您还需要确保“plan”中的值是允许的值(例如,plan1到'4中的一个),然后使用htmlspecialchars()
对其进行转义,以减轻XSS的影响
if (isset($_POST))
{
$post_Plan = isset($_POST['plan']) ? $_POST['plan'] : null;
// etc ...
} else {
// redirect back
}