Jump to content

Handling Return Strings


325ey

Recommended Posts

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!

 

Link to comment
https://forums.phpfreaks.com/topic/182820-handling-return-strings/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.