简体   繁体   English

在 php 页面上执行操作的 URL

[英]URL performing an action on a php page

I have a web form that when used creates a URL that can be used to take you back to the web form - populating the form as you did originally.我有一个 Web 表单,在使用时会创建一个 URL,可用于将您带回 Web 表单 - 像最初一样填充表单。

So for example, if you filled in the 'update' and 'update time' fields, the URL created would have this added:因此,例如,如果您填写了“更新”和“更新时间”字段,则创建的 URL 将添加以下内容:

$url .= "&update=".$update;
$url .= "&upd_time=".$upd_time;

I have added checkboxes to the form, and want the boxes a user selected show as selected originally to show as checked again, when using the URL to return to the form.我在表单中添加了复选框,并希望在使用 URL 返回表单时,用户选择的框显示为最初选择的状态,再次显示为选中状态。

Is that possible - hopefully I have explained that clearly..这可能吗 - 希望我已经解释清楚了..

You can set in URL &checkbox=1 and then use this code to retrieve if the checkbox were checked or not:您可以在 URL &checkbox=1 中设置,然后使用此代码来检索复选框是否被选中:

$checked = $_GET['checkbox'] == "1" ? "checked" : "";

Then you can write in your html form然后你可以写在你的html表单中

<input type="checkbox" name="checkbox" <?=$checked?> >

If the URL checkbox is 1 then the PHP code write in the html input the checked attribute for display the input as checked.如果 URL 复选框为 1,则 PHP 代码会在 html 输入中写入已选中的属性,以便将输入显示为已选中。

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

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