Forum Moderators: coopster

Message Too Old, No Replies

Verify Data From Array on $_POST

How to verify data from an array when a form is posted.

         

ScottDonald

5:58 am on Dec 11, 2004 (gmt 0)

10+ Year Member



Hi,
I am building a script to manage game servers, as in rcon.

Currently i have made login form a drop down box with an array of server IP address, $servers
And the form inputs those IP address into the drop down, then the user types in his server PORT and rcon password.

The login verifys this data via the game server through a udp packet.

Problam is, i dont want people whos game server ip addys arn't in the array to be able to login. Currently this can be easily done my copying the form to another site and removing the drop down with a text field.

What i want to work out is how i can make the process when the login button is clicked to check and see if the post of $_POST['server_ip'] is in the array of $servers

If anyone can help with this i would be most apprciative.

Heres my if statement when you click login


if (
!empty($_POST['server_ip']) &&
!empty($_POST['server_pass']) &&
!empty($_POST['server_port']) &&
// this is where the new part should go

Thanks in advance,
Scott Donald

ScottDonald

8:33 am on Dec 11, 2004 (gmt 0)

10+ Year Member



mission resolved

used a custom binary_search function to look in the array for the matching IP address

ergophobe

9:04 am on Dec 11, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Welcome to WebmasterWorld Scott. I hope we can actually be of assistance some day!

cyhcto

9:49 am on Dec 11, 2004 (gmt 0)

10+ Year Member



I won't code it since you found a solution and it's late, but it wouldn't have been much more than

if (in_array($server, $_POST['server_ip']) {
get_jiggy_wit_it()
}

Or something like that. Hmm. I pity the next guy that has to deal with my code.

cyhcto

9:51 am on Dec 11, 2004 (gmt 0)

10+ Year Member



Pat, could I buy another ")" for the end of that condition?

G'nite.

ScottDonald

10:30 am on Dec 11, 2004 (gmt 0)

10+ Year Member



that wouldnt work

i was searching an array with integers

hence there needed to be a binary_search function coded

think about issues i say :)
i didnt to start with :(