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 8161177
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:26:32+00:00 2026-06-06T18:26:32+00:00

I have a form that submits to a third-party service that runs some validation.

  • 0

I have a form that submits to a third-party service that runs some validation. On error, it redirects to the same page as the form but appends a query string containing the original form values along with an error message.

Because of this query string, the browser sees it as a “new page” and the form is blank.

I’ve tried one method using PHP (see Code Review question) that boils down to: “grab the GET value for each field, on an individual basis, and then set these as the value on the form.” It sort of works, but:

  • the radio buttons are tricky to deal with
  • I don’t have full PHP functionality. I’m in WordPress with a PHP-in-pages plugin that can run certain PHP but is choking on defining a function and then re-using it

What is the recommended method (PHP or JavaScript… and I do have jQuery on the site also) for re-populating this form?

  • 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-06-06T18:26:34+00:00Added an answer on June 6, 2026 at 6:26 pm

    Unless you are dynamically assembling your fields, it won’t be easy to dynamically repopulate them using PHP. If you are, you can do something like this:

    PHP

    $fields = [
        'username' => ['type' => 'text', 'value' => $_GET['username']],
        'setting1' => ['type' => 'radio', 'value' => $_GET['radio']]
    ];
    foreach( $fields as $name => $input ) {
        echo "<input type='{$input['type']}' name='{$name}' value='{$input['value']}'>";
    }
    

    If not, you can use a combination of PHP and JavaScript like this. I’m using jQuery to simplify things.

    PHP and JavaScript

    $fields = $_GET;
    echo '<script type="text/javascript">
    var errors = { ';
    foreach( $fields as $name => $value ) {
        echo $name . " : '{$value}',\n";
    }
    echo '};
    
    $.each(errors, function(name, value) {
        $("input[name="+name+"]").val(value);
    });
    </script>';
    

    This is untested and I know there is at least one bug (extra comma in the errors array) but should be a good starting point. The goal of the second method is to assemble an array using PHP which the JavaScript can then use and execute a loop to assign those values to each input field. But again – the logic for select boxes and radio buttons and so on will be complex. Instead of just assigning val you would have to set checked properties, etc.

    Unfortunately I don’t know if there are any libraries or jQuery plugins which already do this.

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

Sidebar

Related Questions

I have a form that auto submits and updates the same page. I have
I have a form that the user submits and returns a result, but it
I’m using drupal to create some custom form that submit to a third party,
I currently have a small HTML form for a third party payment service, which
i have a form that submits some data and gets html back. this html
I have a form that submits a search for blogs on my site via
i have a form that submits data to a database, i have a function
i have a PHP contact form that submits data, and an email...: <?php $dbh=mysql_connect
I have a js and html form that submits through php. Once submitted, the
I have a web form that collects information and submits it to a cgi

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.