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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.