Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6208921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:53:24+00:00 2026-05-24T05:53:24+00:00

I know how to it with text inputs. I can easily put a php

  • 0

I know how to it with text inputs. I can easily put a php script in its value, but doing it with input groups seems different. How can I mantain the values of group inputs if the submission of the form fails?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:53:25+00:00Added an answer on May 24, 2026 at 5:53 am

    To re-mark a checkbox or radio button as checked, you use this code:

    <input type="checkbox" name="foo" id="foo" checked="checked"/>
    

    The key is checked="checked".

    If you are using groups of checkboxes, make sure the name of the field ends with brackets [], like this:

     <input type="checkbox" name="foo[]" id="foo_1" value="1" checked="checked"/>
     <input type="checkbox" name="foo[]" id="foo_2" value="2" checked="checked"/>
    

    Then your $_REQUEST['foo'] variable will automatically be an array of checked values. You can use in_array to see if a particular checkbox was checked.

    Update based on comment

    Here’s how I would set it:

    <input type="checkbox" name="foo[]" id="foo_1" value="1" <?= (isset($_POST['foo'] && in_array('1', $_POST['foo'])) ? 'check="checked"' : '' ?>/>
    

    For single items (like radios), use this:

    <input type="radio" name="foo" id="foo" value="1" <?= isset($_POST['radio]) ? 'check="checked"' : '' ?>/>
    

    Hope that helps.

    Update 2:
    Also, make sure you escape user input! Your example should look like this:

    <input type="text" name="username" value="<?php if(isset($_POST['username']) echo htmlspecialchars($_POST['username']);?>">
    

    Always assume the user is trying to hack your system, always escape user input!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know how can i read a value of input text
I know how to replace text in a string. But that's using keyboard (ASCII)
I know that a SQL Server full text index can not index more than
Anyone know of a free xls to text converter that can be run from
Anyone know why CSS provides color for text, but does not have font-color or
Does anyone know how I can prevent the text in a table cell from
I'm looking to fill a text input with a time that the user can
I know I can use MD5 easily in c#, the code I use is
I have a very simple form for data input. Just labels with inputs. But
I'm not sure if many people know about this text-editor? jEdit was kinda big

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.