我恳请您提供有关如何通过URL将变量发送到其他PHP站点的意见:
<form action="deny.php" method="get">
<div align="left"></div>
<p><span class="style13" style="height: 23px;">
<select name="deny" class="style28" style="width: 320px">
<option value="Select" selected="selected">Select</option>
<option value="Price">Too expensive</option>
<option value="Agency">Other Agency</option>
</select>
</span></p>
<p><span class="style13" style="height: 23px;">
<input type="hidden" name="id" value=<? echo $id; ?> />
</span> </p>
<p>
<? echo '<td><a href="deny.php?submit='.$id.'&deny='.$_GET['deny'].'">Send Feedback</a></td>'; ?>
</p>
</form>
$id
是正确的,但$deny
是空
我什至尝试过$deny (instead of $_GET['deny']) and $_POST[deny]
- 但$deny
总是空的。(可在链接中控制(
感谢您的建议!
溴,
斯特凡
用下面的代码替换你的代码:
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<form action="deny.php" method="get">
<div align="left"></div>
<p><span class="style13" style="height: 23px;">
<select name="deny" class="style28" style="width: 320px">
<option value="Select" selected="selected">Select</option>
<option value="Price">Too expensive</option>
<option value="Agency">Other Agency</option>
</select>
</span></p>
<p><span class="style13" style="height: 23px;">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
</span> </p>
<p>
<a href="#" id="feedbackLink">Send Feedback</a>
</p>
</form>
<script type="text/javascript">
$( document ).ready(function() {
$('select[name="deny"]').change(function(){
var link = 'deny.php?submit=<?php echo $id; ?>&deny=';
$('a#feedbackLink').attr('href', link + $(this).val());
});
$('select[name="deny"]').trigger('change');
});
</script>
如果不提交表单,您不能使用 $_GET、$_POST 等变量。
希望这将解决您的问题。
在
将表单提交到当前脚本之前,不会填充$_GET['deny']
。
不要尝试使用 PHP 来构造 URL。让浏览器来做。只需在表单中放置一个提交按钮,并进行适当的输入和操作。这就是形式的用途。
<form action="deny.php" method="get">
<div align="left"></div>
<p><span class="style13" style="height: 23px;">
<select name="deny" class="style28" style="width: 320px">
<option value="Select" selected="selected">Select</option>
<option value="Price">Too expensive</option>
<option value="Agency">Other Agency</option>
</select>
</span></p>
<p><span class="style13" style="height: 23px;">
</span> </p>
<p>
<input type="submit" value="submit">
</p>
</form>
<form action="deny.php" method="get">
<div align="left"></div>
<p>
<span class="style13" style="height: 23px;">
<select name="deny" class="style28" style="width: 320px">
<option value="Select" selected="selected">Select</option>
<option value="Price">Too expensive</option>
<option value="Agency">Other Agency</option>
</select>
</span>
</p>
<p>
<span class="style13" style="height: 23px;">
<input type="hidden" name="id" value="<?php echo $id; ?>" />
</span>
</p>
<p>
<input type="submit" value="Send Feedback" value="submit" />
</p>
</form>
<?php
if (isset($_GET)) {
var_dump($_GET);
}
?>
<form action="/deny.php?id=<? $id ?>" method="get">
<input name="submit" type="submit" value="Feedback" />
做了诀窍:-(
谢谢
斯特凡
试试这个,它已经过测试。
<form action="your_page.php" method="GET"> <!--you may use POST for security as well -->
<select name="deny">
<option value="">Select Option</option>
<option value="Price">Too expensive</option>
<option value="Agency">Other Agency</option>
</select>
<!-- you msut have $id = something -->
<input type="hidden" name="id" value="<?php echo $id; ?>" />
<input type="submit" value="Send Feedback" value="submit" />
</form>
<?php
echo "<pre>";print_r(($_GET));
?>