isset $_GET

Junior Spellweaver
Joined
Jan 25, 2012
Messages
114
Reaction score
4
Hello Ragezone

I`m working to a new script but i have a issues

Let me tell about it.

PHP:
<?php

header('Content-type: text/xml');

$key = isset($_GET['licensekey']) ? $_GET['licensekey'] : null;
$templateid = isset($_GET['templateid']) ? $_GET['templateid'] : null;

if (!($key && $template)) {
    echo file_get_contents('xml/invalidkey.xml');
}

if ($key === 'developer') {
    echo file_get_contents('xml/gamelist.xml');
    return;
}
if (3 === (int) $templateid) {
    echo file_get_contents('xml/templateid/counterstrike.xml');
    return;
} 


?>

What is the my issues.

the name of script is like gameimport.php

when I imput
gameimport?licensekey=KEY

It`s imput both xml/invalidkey.xml' xml/gamelist.xml' together in 1 request like open 2 file in same time but in 1 file.

Where i mistake.

What i want do to?

When i request gameimport.php just echo xml/invalidkey.xml'
When i request gameimport.php?licensekey=NotVALID echo xml/invalidkey.xml'
Whe i request gameimport.php?licensekey=developer is valid key echo xml/gamelist.xml'
If i request the last request gameimport.php?licensekey=developer&templateid=ID echo xml/templateid/counterstrike.xml

Thank you and i hope you understand my bad lang.

Kind Regards,
Cristian
 
You have to use else-if statements, or exit after outputting the contents of the XML file.
 
Thank you for responding.

Well same error is put in same file

Whit your script when i request only gameimport.php

XML Parsing Error: XML or text declaration not at start of entity

When i request gameimport.php?licensekey=developer

Same loading only the invalidkey.xml

I test whit same script but i remove the xml so

When i request gameimport.php

i put echo 'do something ';

When i request gameimport.php?licensekey=developer

same echo not change in request licensekey

PHP:
 <?php 


if(isset($_GET['licensekey']) && isset($_GET['templateid']))
{
    if($_GET['licensekey'] == "developer")
    {
        echo 'do something'; 
    }
    elseif($_GET['templateid'] == 3)
    {
        echo 'here is your template'; 
    }
    else
    {
        echo 'the template id and licensekey is invalid'; 
    }
}
else
{
   echo 'invalid';
}
?>

You can test this you will see is not working
 
PHP:
 <?php



$key = isset($_GET['licensekey']) ? $_GET['licensekey'] : null;
$templateid = isset($_GET['templateid']) ? $_GET['templateid'] : null;

if (!($key && $template)) {
    echo 'key and template invalid';
}

if ($key === 'developer') {
    echo 'licensekey is valid';
    return;
}
if (3 === (int) $templateid) {
    echo 'templateid is valid';
    return;
} 


?>

Ok so when i request

gameimport.php

key and template invalid

When i request gameimport.php?licensekey=developer

key and template invalidlicensekey is valid

You see i whant key and template invalid remove just add licensekey is valid not together

Thank you
 
PHP:
 <?php



$key = isset($_GET['licensekey']) ? $_GET['licensekey'] : null;
$templateid = isset($_GET['templateid']) ? $_GET['templateid'] : null;

if (!($key && $template)) {
    echo 'key and template invalid';
}

if ($key === 'developer') {
    echo 'licensekey is valid';
    return;
}
if (3 === (int) $templateid) {
    echo 'templateid is valid';
    return;
} 


?>

Ok so when i request

gameimport.php

key and template invalid

When i request gameimport.php?licensekey=developer

key and template invalidlicensekey is valid

You see i whant key and template invalid remove just add licensekey is valid not together

Thank you

I have no idea what you meant to say.
 
Ok try to imput this script in your apache

So when i request

myscript.php

automatic is loading
PHP:
if (!($key && $template)) {
    echo 'key and template invalid';
}

key and template invalid

now when i request
myscript.php?licensekey=developer

PHP:
if ($key === 'developer') {
    echo 'licensekey is valid';
    return;
}

Working perfect but the issues is

when you request myscript.php?licensekey=developer

is loading the both function in same time

so finally will loading 2 echo not just 1

PHP:
if (!($key && $template)) {
    echo 'key and template invalid';
}

if ($key === 'developer') {
    echo 'licensekey is valid';
    return;
}

and finally when you request the myscrip.php?licensekey=developer

echo 'key and template invalid';
echo 'licensekey is valid';

Hope now you understand
 
Now i put return in key && template

When i request myscript.php?licensekey=developer

Same echo do not change if key == developer
 
Just try yours self and you will see the script do not work .

when imput gamepanel.php?licensekey=developer

is not working

when you remove return; from key && template is validate but the issues is put the 2 echo in the request licensekey=developer

Something is not okay.
 
Just try yours self and you will see the script do not work .

when imput gamepanel.php?licensekey=developer

is not working

when you remove return; from key && template is validate but the issues is put the 2 echo in the request licensekey=developer

Something is not okay.

PHP:
<?php
$key = isset($_GET['licensekey']) ? $_GET['licensekey'] : null;
$templateid = isset($_GET['templateid']) ? $_GET['templateid'] : null;

if (!$key && !$templateid) {
    echo 'key and template invalid';
    return;
}

if ($key === 'developer') {
    echo 'licensekey is valid';
    return;
}
if (3 === (int) $templateid) {
    echo 'templateid is valid';
    return;
} 

?>

Read this before continuing.
 
Perfect ;;) now the last is remaining

myscript.php?licensekey=developer&templateid=3

When i give this link is return only to myscript.php?licensekey=developer

so whit your modification will be this

myscript.php give echo key and template invalid

Perfect

now myscript.php?licensekey=developer

give echo licensekey is valid

perfect
now
myscript.php?licensekey=developer&templateid=3

give echo licensekey is valid

in this must give echo echo 'templateid is valid';

Thank you so much

Hope will fix it

PS: When i put myscript.php?licensekey=1&templateid=3

echo templateid is valid

I see working perfect but i need to remove the licensekey

I want to authenticity only if valid key
 
Wizkidje thank you so much for help.


No problem is okey i will try to find a solution

Kind Regards,
Cristian G. Danasel
 
Back