简体   繁体   English

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

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

I have a page name index.php In page index.php there is many url like我有一个页面名称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?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. I want whenever someone click on http://index2.php?userid=2 on page one it automatically fill the data on next page input text with 2我希望每当有人在第一页点击http://index2.php?userid=2时,它会自动用2填充下一页输入文本上的数据

When routing to the URL http://index2.php/?user=2 , you can access the GET superglobal values as follows:路由到 URL http://index2.php/?user=2时,您可以访问 GET 超全局值,如下所示:

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

If you want this to be the value of your input you could do the following:如果您希望这是您输入的值,您可以执行以下操作:

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

Use Ajax to send data from one page to another.使用 Ajax 将数据从一页发送到另一页。

On Index.php Page在索引.php 页

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

On next_page.php在 next_page.php

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

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

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