繁体   English   中英

Html 如何将数据从一页发送到另一页

[英]Html how send data from one page to another page

我有一个页面名称index.php在页面 index.php 中有很多 url 之类的

http://index2.php?user=2 , http://index2.php?user=3 and so on.On my local host there is a page name index2.php and there is a text box with name user. 我希望每当有人在第一页点击http://index2.php?userid=2时,它会自动用2填充下一页输入文本上的数据

路由到 URL http://index2.php/?user=2时,您可以访问 GET 超全局值,如下所示:

<?php $selected_user = $_GET['user'];/>

如果您希望这是您输入的值,您可以执行以下操作:

<input type="text" value="<?php echo $selected_user;?>">

使用 Ajax 将数据从一页发送到另一页。

在索引.php 页

 $user=$_GET['user'];
 $.ajax({  
        type: 'POST',  
        url: 'next_page.php', 
        data: { user: <?php echo $_GET['user']; ?> },
        success: function(response) {
        }
    });

在 next_page.php

$user= $_POST['user'];
echo $user;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM