php ~ array modification
IamMrRay
Otis, MA
I have a nearly complete e-commerce site that I am working on, except I ran into a little road block currently. I have a weak point when it comes to arrays.
What I am trying to do is take any combination of values from a form on a previous page and then take those values out of the array and then concatenate them into a query string.
So far I have the implode working.
But beyond that, I am not sure if it is just making extra work.
I was thinking that perhaps I could check the string for certain values and then just based on those being present, make the query based on what was detected. I think if I actually do it like this it will isolate user input from the query, and make a more secure form.
What do you think?
And would it really be necessary to still implode the array if I used the second idea?
What I am trying to do is take any combination of values from a form on a previous page and then take those values out of the array and then concatenate them into a query string.
So far I have the implode working.
But beyond that, I am not sure if it is just making extra work.
I was thinking that perhaps I could check the string for certain values and then just based on those being present, make the query based on what was detected. I think if I actually do it like this it will isolate user input from the query, and make a more secure form.
What do you think?
And would it really be necessary to still implode the array if I used the second idea?
0
Comments
what if I just set up a bunch of conditionals like this:
$arraything = stripslashes(trim($_GET));
<?php
if($arraything == "what we want"){
$this_certain_section_of_query = "thing_searched_in_query =\'blah\'";
}
$query = "select * from blahblah where blahblahblah ='blahblahblahblah' and $this_certain_section_of_query";