Jump to content

isset function help


victorianrider

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/219034-isset-function-help/
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/219034-isset-function-help/#findComment-1135898
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/219034-isset-function-help/#findComment-1135900
Share on other sites

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;
}

?>

Link to comment
https://forums.phpfreaks.com/topic/219034-isset-function-help/#findComment-1135904
Share on other sites

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']

Link to comment
https://forums.phpfreaks.com/topic/219034-isset-function-help/#findComment-1135908
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.