Jump to content

$_GET problem when using $GET['screen_check']


python01

Recommended Posts

I am working on mobile workpage which would get variable passed in url and based on that id populate the webpage with information from database.

I am also using the $GET['screen_check'] to get devices screen resolution.

When I click on the link for example webpage.com/index.php?id=2

the id=2 part gets overwritten with the display resolution info and the information I am looking for does not appear.

I have the $id=$GET_['id'] above the screen_check script so I think it should work but it does not

What would be the correct way to do them both in the same php file?

 

Thanks.

Link to comment
Share on other sites

$_GET['key'], not $GET

 

 

<?php
$PropertyID = $_GET["ID"];
?>

<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"/>
</head>
<?php

if(!isset($_GET['screen_check']))
{
/* This code will be executed if screen resolution has not been detected.*/
echo "<script language='JavaScript'>
<!-- 
document.location=\"$PHP_SELF?screen_check=done&Width=\"+screen.width+\"&Height=\"+screen.height;
//-->
</script>";
}
else 
{    
/* This code will be executed after screen resolution is detected.*/
    if(isset($_GET['Width'])){// && isset($_GET['Height'])) 
	// Resolution  detected
$ScreenWidth=$_GET['Width'];

     }
     else {
               // Resolution not detected
               	$ScreenWidth=235;
     }
}
echo "Screen width = ".$ScreenWidth;

?> 

If I do

echo $PropertyID;

 

nothing shows up so it looks that the variable is empty and did not get the value from $_GET.

 

What am I doing wrong here?

Link to comment
Share on other sites

not sure if it will help but here is my actual URL being typed in/linked:

http://www.lottocomplete.com/textback/mweb/index.php?ID=2

after the enter here is what I have in the URL field:

http://www.lottocomplete.com/textback/mweb/index.php?screen_check=done&Width=1366&Height=768

I thought that before the URL gets replaced with the screen_check variables the ID would be saved to variable since it is the first thing in my program but for what ever reason it is not happening.

Is there any way to combine these variables being passed? Is my initial URL correct?

Is my problem completely something different?

If I insert $PropertyID=2; somwhere in my code everything is working fine so I know the reminder of the code is working it is just the passing of the variable that causing my headache right now.

 

Link to comment
Share on other sites

Most of the problem is because $PHP_SELF was depreciated over 10 years ago, throws a depreciated error in php5.3 when turned on (where the depreciated error was introduced), and has been completely removed as of php5.4. Also, the current variable to reference php_self - $_SERVER['PHP_SELF'] seems to randomly change without any documentation between having and not having the get parameters as part of it.

 

You need to build the URL in your javascript differently. Since your code has the $_GET['ID'] in $PropertyID, why not deliberately build the URL using that -

 

 

	echo "<script language='JavaScript'>
<!-- 
document.location=\"?ID=$PropertyID&screen_check=done&Width=\"+screen.width+\"&Height=\"+screen.height;
//-->
</script>";

 

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.