rpg711 Posted April 18, 2011 Share Posted April 18, 2011 I'm a total noob at PHP, and need to make a simple authentication server-side script for a Java application that is in no way associated with the server. My Java app URL encodes in this format(pretty standard): "key1"="value1" I THINK I have the correct code in PHP to read the HTTP POST data values... $username = array("1", 2, 3, 4, 5); $match = FALSE; foreach($_POST as $key1 => $value1){ foreach($username as $key2 => $value2){ if ($value1 == $value2){ $match = TRUE; break; } } if ($match = TRUE) break; } After all this I'd like to send a response saying either TRUE or FALSE(in other words, I'd like to send the variable $match). I've looked far and wide for how to do this in PHP, and couldn't find a single helpful page. Quote Link to comment https://forums.phpfreaks.com/topic/234068-help-recieving-a-post-from-external-client-and-then-sending-custom-response/ Share on other sites More sharing options...
micah1701 Posted April 18, 2011 Share Posted April 18, 2011 if you're sending it in the URL you need to use $_GET and not $_POST also... <?php $username = array("1", 2, 3, 4, 5); $match = false; foreach($_GET as $key1 => $value1){ if(in_array($value1,$username)){ $match = true; break; } } if($match){ echo "true"; }else{ echo "false"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/234068-help-recieving-a-post-from-external-client-and-then-sending-custom-response/#findComment-1203065 Share on other sites More sharing options...
rpg711 Posted April 18, 2011 Author Share Posted April 18, 2011 <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> Array [string] => testuser true</body> null It was $_POST, but thank you so much for the help! I managed to get it to work Quote Link to comment https://forums.phpfreaks.com/topic/234068-help-recieving-a-post-from-external-client-and-then-sending-custom-response/#findComment-1203129 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.