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
https://forums.phpfreaks.com/topic/264457-_get-problem-when-using-getscreen_check/
Share on other sites

  Quote

$_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?

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.

 

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

 

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.