turpentyne Posted September 12, 2010 Share Posted September 12, 2010 I have a php search page that takes form data to create its queries, then reload the original search page. The form is long, so there are numerous $_POST's to convert to variables for use in the query. I've looked at "extract" and a few other code snippets. But it's a form and I don't want any security issues. I'm hoping there's a "foreach" solution, but I'm a beginner. What's a proper way to to simplify this: $s1 = $_POST["s1"]; $s2 = $_POST["s2"]; $s3 = $_POST["s3"]; $s4 = $_POST["s4"]; $s5 = $_POST["s5"]; $s6 = $_POST["s6"]; $s7 = $_POST["s7"]; $s8 = $_POST["s8"]; $s9 = $_POST["s9"]; $s10 = $_POST["s10"]; $s11 = $_POST["s11"]; $s12 = $_POST["s12"]; Quote Link to comment https://forums.phpfreaks.com/topic/213232-foreach-on-a-sequence-of-_post-or-_get-variables/ Share on other sites More sharing options...
sasa Posted September 12, 2010 Share Posted September 12, 2010 named your form fields as array in your input tags change name="s1" to name="s[1]" and so on Quote Link to comment https://forums.phpfreaks.com/topic/213232-foreach-on-a-sequence-of-_post-or-_get-variables/#findComment-1110323 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.