简体   繁体   English

PHP-使用帖子进行同一页面回调

[英]PHP - Same Page Call Back Using Post

I have an array in php containing details to do with an application, for example an id, a name, a date created an invoice and so on. 我在php中有一个数组,其中包含与应用程序相关的详细信息,例如id,名称,创建发票的日期等。

I am currently displaying to the user the application name as a URL so that ideally when they click it they can see some other details that I can look up from the database based on the attributes above. 我目前正在向用户显示应用程序名称作为URL,以便理想情况下,当他们单击它时,他们可以看到一些其他细节,这些细节我可以基于上述属性从数据库中查找。

I recall during university a few years ago that I can use POST with an html form to send this - correct? 我记得几年前在大学期间,可以将POST与HTML表单一起使用来发送此消息-对吗? However i am a little confused as I don't really need any information to be shown to the user in terms of a form - for example no input box is needed, the submit button really is the link I am providing and so on. 但是我有点困惑,因为我真的不需要任何信息以表单的形式显示给用户-例如,不需要输入框,提交按钮确实是我提供的链接,依此类推。

In this case how do I create a solution using my URL approach to call back to the current page 在这种情况下,如何使用URL方法创建解决方案以回调到当前页面

For example something like this works with GET 例如,类似的东西可以在GET中使用

<a href="./display.php?data=Data1&data2=Data120">Click here</a>


<?php
    if(isset($_GET["data"]) && isset($_GET["data2"]))
    {
        $data = $_GET["data"];
        $data2 = $_GET["data2"];
    }
?>

But using via GET is not ideal as it will allow others to guess personal information which would be an issue 但是通过GET使用并不理想,因为它会使其他人猜测个人信息,这将是一个问题

try passing some parameters using $_GET. 尝试使用$ _GET传递一些参数。 That way the user will be able to view some parameters in the ULR page, but you wont need another page to show this user their details. 这样,用户将能够在ULR页面中查看某些参数,但是您将不需要其他页面来向该用户显示其详细信息。

You can use form with hidden element and only visible element is button... 您可以将表单与隐藏元素一起使用,只有可见元素是按钮...

<form method="post">
    <input type="hidden" />
</form>

Something like this... 像这样

Then try using jquery to show/hide some page content. 然后尝试使用jquery显示/隐藏一些页面内容。 for example: 例如:

<a onClick="document.getElementById('option1').style.display='block';">click me</a> 
<div= id='option1' style='display: none;'>
some hidden content. when you click the link, it will be visible
</div>

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

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