duanmaduan1848 2014-05-22 03:39
浏览 60
已采纳

PHP - 如何从隐藏输入类型和$ _POST到另一个PHP获取名称?

I wish can pass the value of getvenueurl to another php named map.php .

I use input type hidden to to echo in current page:

<input type="hidden" name="getvenueurl" value="<?php echo $show_venue['url']; ?>"/>

and I wish when i click the button <a href="map.php" target="_blank"><input type="button" class="button" value="MAP" style="width:100px;"> in map.php show the correct value of getvenueurl.

In current page:

 <?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>&nbsp;<b>Address : </b><?php echo $show_venue['address']; ?></p>
        <p>&nbsp;<b>Detail : </b><?php echo $show_venue['detail']; ?></p>
        <b>&nbsp;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>

I have try to use session to pass the value of getvenueurl but seen it is failed, because it will only show the last column value for all output that in while loop.

In map.php:

    <table class="mapping">
    <tr>
    <td>
        <?php
        $theurl = $_SESSION['theurl'];
         echo $theurl;?>
    </td>
    </tr>
</table>

How can I get the correct value to my map.php ?

  • 写回答

3条回答 默认 最新

  • dongyue6199 2014-05-22 03:47
    关注

    u can pass value through anchor tag this way..i hope this will help u.

    <a  href="map.php?getvenueurl=<?php echo $show_venue['url']; ?>" target="_blank"><input type="button"  class="button" value="MAP" style="width:100px;"></a>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 数字取证课程 关于FAT文件系统的操作
  • ¥15 如何使用js实现打印时每页设置统一的标题
  • ¥15 安装TIA PortalV15.1报错
  • ¥15 能把水桶搬到饮水机的机械设计
  • ¥15 Android Studio中如何把H5逻辑放在Assets 文件夹中以实现将h5代码打包为apk
  • ¥15 使用小程序wx.createWebAudioContext()开发节拍器
  • ¥15 关于#爬虫#的问题:请问HMDB代谢物爬虫的那个工具可以提供一下吗
  • ¥15 vue3+electron打包获取本地视频属性,文件夹里面有ffprobe.exe 文件还会报错这是什么原因呢?
  • ¥20 用51单片机控制急停。
  • ¥15 孟德尔随机化结果不一致