我请求您提供如何通过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>
&#13;
$id
是正确的,但$deny
为空
我甚至尝试使用$deny (instead of $_GET['deny']) and $_POST[deny]
- 但$deny
始终为空。 (可以在链接中控制)
感谢您的建议!
BR,
的Stefan
答案 0 :(得分:2)
用以下代码替换您的代码:
<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等变量。
希望这能解决您的问题。
答案 1 :(得分:1)
$_GET['deny']
不会被填充。
请勿尝试使用PHP构建网址。让浏览器做到这一点。只需在表单中放置一个提交按钮,并有适当的输入和操作。那是什么形式。
答案 2 :(得分:1)
<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>
答案 3 :(得分:0)
<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);
}
?>
答案 4 :(得分:0)
<form action="/deny.php?id=<? $id ?>" method="get">
<input name="submit" type="submit" value="Feedback" />
诀窍:-)
谢谢,
的Stefan
答案 5 :(得分:0)
尝试这个,它已经过测试。
<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));
?>