简体   繁体   中英

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.

So for example, if you filled in the 'update' and 'update time' fields, the URL created would have this added:

$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.

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:

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

Then you can write in your html form

<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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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