如何从隐藏的输入类型和$_POST中获取名称到另一个PHP
PHP - How can I get the name from input type hidden and $_POST to another php?
我希望可以将getvenueurl
的值传递给另一个名为map.php的php。
我使用隐藏的输入类型来回显当前页面:
<input type="hidden" name="getvenueurl" value="<?php echo $show_venue['url']; ?>"/>
和我希望当我点击按钮<a href="map.php" target="_blank"><input type="button" class="button" value="MAP" style="width:100px;">
在map.php显示getvenueurl
的正确值。
当前页:
<?php
$read_venue = mysql_query("select * from venue where theme_name = '$title'");
while($show_venue = mysql_fetch_array($read_venue))
{
?>
<form method="post" action="#tab5">
<center><table border="1" class="venuetb">
<tr>
<input type="hidden" name="getvenue" value="<?php echo $show_venue['venue']; ?>"/>
<input type="hidden" name="getvenueprice" value="<?php echo $show_venue['price']; ?>"/>
<input type="hidden" name="getvenueurl" value="<?php echo $show_venue['url']; ?>"/>
<td style="width:20%;"><center><div class="imgvenue"><img src="<?php echo 'venueimg/'.$show_venue['venueimg']; ?>" /></div></center></td>
<td ><center><div class="bine"><?php echo $show_venue['venue']; ?> - RM <?php echo $show_venue['price']; ?></div></center></br>
<div class="dv"><p> <b>Address : </b><?php echo $show_venue['address']; ?></p>
<p> <b>Detail : </b><?php echo $show_venue['detail']; ?></p>
<b> Contact No: </b><?php echo $show_venue['contact']; ?></div>
</td>
<td style="width:20%;">
<center><a href="map.php" target="_blank"><input type="button" class="button" value="MAP" style="width:100px;"></a>
<input type="submit" class="button" style="width:100px;" value="CHOOSE" name="choose_venue"></center>
</td>
</tr>
</table></center><br>
</form>
<?php
$_SESSION['theurl'] = $show_venue['url'];
}
?>
<?php
if(isset($_POST['choose_venue']))
{
$getvenue = $_POST['getvenue'];
$getvenueprice = $_POST['getvenueprice'];
$savevenue = mysql_query("insert into selectvenue(user,title,venuename,venueprice) values('$username','$title','$getvenue','$getvenueprice')");
if($savevenue)
{
echo"<center>$getvenue save.</center>";
}
else
{
echo "Failed.";
}
}
?>
</div>
我尝试使用会话来传递getvenueurl
的值,但看到它失败了,因为它只会显示while循环中所有输出的最后一列值。
<table class="mapping">
<tr>
<td>
<?php
$theurl = $_SESSION['theurl'];
echo $theurl;?>
</td>
</tr>
</table>
如何获得正确的值到我的map.php
你可以通过这种方式通过锚标记传递值,我希望这对你有帮助。
<a href="map.php?getvenueurl=<?php echo $show_venue['url']; ?>" target="_blank"><input type="button" class="button" value="MAP" style="width:100px;"></a>
代替
<a href="map.php" target="_blank"><input type="button" class="button" value="MAP" style="width:100px;"></a>
写下面的代码
<input type="button" class="button" onclick="submit_to_map()" value="MAP" style="width:100px;">
然后将此javascript代码放到页面上。
<script type="text/javascript">
function submit_to_map() {
var form = document.getElementById("form-id");
form.action = "map.php";
form.submit();
}
</script>
然后,您可以从map.php中获得表单中使用$_POST[]的所有元素的值。希望对大家有所帮助
确认每页的开头都有<?php session_start(); ?>
相关文章:
- 如何在php文件中获取$.post-ajax传递的值
- 如何从HTTP上下文对象中获取Post数据
- 如何使用Javascript获取POST请求填充的元素的值
- 以json形式获取post-response
- 可以'当window.location.href时,无法从javascript获取post值
- AJAX请求php获取post/get发送的指定目录中服务器上的文件列表(无JQUERY)
- PHP没有从$.ajax获取POST数据
- 获取post-jquery并在$_post中回显它(这可能吗?)
- 如何使用 AJAX 发送 POST 数据?以及如何在Web API中获取POST数据
- 如何从 Javascript AJAX 调用中获取 POST 值到 php
- 如何在jQuery中获取POST变量
- 从通过 echo 语句动态添加的表单元素中获取 POST 值
- 通过 AJAX 获取 POST 数据
- 通过 PHP 中的对象从提交按钮获取 POST
- 通过通知 URL 在 Meteor 中获取 POST 请求
- Meteor Iron路由器如何获取POST数据
- 如何通过javascript获取post()方法参数
- 在动态输入区域jquery中获取post数组以插入批代码点火器
- 如何将XMLHTTPRequest与POST和params一起正确使用?PHP未获取POST信息
- 如何在使用javascript提交表单之前获取POST内容