325ey Posted November 24, 2009 Share Posted November 24, 2009 Hello, I'm trying to handle a return string (sent as a URL) from an attempted form submission where there has been a validation issue with the data submitted. The return string looks something like: www mydomain.com?error_attribute0=PHONE&error_value0=1234567&error_attribute1=EMAIL&error_value1=abcdefg etc... Where error_attribute[ ] is the name of the form field which has not validated and error_value[ ] is the value for that field which was submitted. The string also includes individual elements for each form field sent, named as the form field, so using the above example the complete string looks like: www mydomain.com?error_attribute0=PHONE&error_value0=1234567&error_attribute1=EMAIL&error_value1=abcdefg&PHONE=1234567&EMAIL=abcdefg ...plus any other fields which didn’t invalidate. I know there are a number of ways to handle this string and present the form to the user for revalidation – my question is what’s the best way to do it? My idea is to present the form with the original values repopulated using session variables to save stripping them from the string, then to highlight the invalid fields based on variables manufactured using the error_attribute[ ] element. I can grab the query string and parse this into an array, but am unsure on how to grab each occurrence of error_attribute[ ] and turn each one into a variable. Help, or another way of solving this issue would be great! I don’t control the system the form is being submitted to, my PHP skills are not advanced although I do understand the concept of Arrays, Variables etc... Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/182820-handling-return-strings/ Share on other sites More sharing options...
mikesta707 Posted November 24, 2009 Share Posted November 24, 2009 assuming you entered firstname, and lastname into the two boxes above, the $_GET array would look something like $_GET: textFields (array) => 0 => firstname 1 => lastname //other stuff Quote Link to comment https://forums.phpfreaks.com/topic/182820-handling-return-strings/#findComment-964938 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.