victorianrider Posted November 18, 2010 Share Posted November 18, 2010 Hi, just began working with the isset function, and having a few problems with the following code. As you can see I'm trying to assign some variables using the explode function. This is the string that is taken from the form on my index page http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/refresh_stat_manual?user_id=100000898907997&auth_key=e5f4a2308d13346b4bf6e8228e9f50636240bf9f&nocache=1290001265332& $RawHeader = str_replace(' ', '', $_POST['RawHeader']); if (isset($RawHeader)) { $UserID = explode('user_id=', $RawHeader); $UserID = explode('&', $UserID[1]); $UserID = $UserID[0]; $AuthKey = explode('auth_key=', $RawHeader); $AuthKey = explode('&nocache=', $AuthKey[1]); $AuthKey = $AuthKey[0]; } I am new to the isset function so I don't really know if there is anything wrong with it, but if I try echo out both $UserID and $AuthKey it returns nothing. Any suggestions or solutions? Thanks Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted November 18, 2010 Share Posted November 18, 2010 Is there any particular reason why you are posting the $rawHeader variable? Are these just from the $_GET parameters of the URL provided? (e.g. this is the page this script runs on) http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/refresh_stat_manual?user_id=100000898907997&auth_key=e5f4a2308d13346b4bf6e8228e9f50636240bf9f&nocache=1290001265332 Quote Link to comment Share on other sites More sharing options...
victorianrider Posted November 18, 2010 Author Share Posted November 18, 2010 Is there any particular reason why you are posting the $rawHeader variable? Are these just from the $_GET parameters of the URL provided? (e.g. this is the page this script runs on) http://mobsters-fb-apache-dynamic-lb.playdom.com/mob_fb/refresh_stat_manual?user_id=100000898907997&auth_key=e5f4a2308d13346b4bf6e8228e9f50636240bf9f&nocache=1290001265332 No, I'm trying to use this $RawHeader var from this page here http://www.hiredgunkillers.com/betamate/index.php Instead of the user manually splitting up their own user_id and auth_key and pasting them into the 2 text boxes, I wanted to make it easier and for them to paste the whole header. Quote Link to comment Share on other sites More sharing options...
victorianrider Posted November 18, 2010 Author Share Posted November 18, 2010 OR Just paste in any header in here and I will sort it out cause I am just that nice <input type="text" name="RawHeader" /><br/> That's from the index.php page Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted November 18, 2010 Share Posted November 18, 2010 Ok, so if I understand you correctly, this should work: <?php $postVar = "user_id=100000898907997&auth_key=e5f4a2308d13346b4bf6e8228e9f50636240bf9f&nocache=1290001265332&"; // $postVar = trim($_POST['RawHeader']); if (!empty($postVar)) { $output = array(); parse_str($postVar, $output); $userID = isset($output['user_id']) ? $output['user_id'] : ""; $authKey = isset($output['auth_key']) ? $output['auth_key'] : ""; echo $userID."<br />".$authKey; } ?> Quote Link to comment Share on other sites More sharing options...
victorianrider Posted November 18, 2010 Author Share Posted November 18, 2010 Ok, so if I understand you correctly, this should work: <?php $postVar = "user_id=100000898907997&auth_key=e5f4a2308d13346b4bf6e8228e9f50636240bf9f&nocache=1290001265332&"; // $postVar = trim($_POST['RawHeader']); if (!empty($postVar)) { $output = array(); parse_str($postVar, $output); $userID = isset($output['user_id']) ? $output['user_id'] : ""; $authKey = isset($output['auth_key']) ? $output['auth_key'] : ""; echo $userID."<br />".$authKey; } ?> That would work just fine if the user ID and auth key were not dynamic, but there are going to be 1000's of people using this, all of which have unique IDs and auth keys. So this would only work for that 1 account. That's why I need it to work from $_POST['RawHeader'] Quote Link to comment Share on other sites More sharing options...
spfoonnewb Posted November 18, 2010 Share Posted November 18, 2010 I'm not sure I follow. You could replace the string I used (for testing purposes) with $postVar = trim($_POST['RawHeader']); Are you saying that there will be multiple user_id's and auth_key's in the single string? Quote Link to comment 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.