Php Tutorial Guide - How To Show Screen Resolution Find Display Script
Posted On Wed Nov 29, 2006 By leni In PHP Forums And Topics Discussions About Hyper Text Programming Language Forums
One way to find a user's screen resolution with php is with the $HTTP_COOKIE_VARS function.
This post tutorial guide will show you how to retrieve, get, show, display, find your weg page (site) visitors screen resolution.
NOTE: for this function to work, you will need to have PHP, if you don't have PHP on your website, we recommend our friends at www.webune.com for PHP hosting. check them out.
the first thing to do is to copy and past this sample code into your editor, you can use notepad it you like:
now save it as show-user-screen-resolution-php.php and upload it to your website.
after you have uploaded to your website, open the file with your browser (example: yourdomain.com/show-user-screen-resolution-php.php)
after you have opened it, you will see your own screen resolution display on the screen.
Our friends at www.webune.com have provided us with free hosting to demonstrate how this script works.
NOTE: you will require to be hosted on a site that has PHP. If you need PHP web hosting, www.webune.com has great PHP packages available, I recommend them cuz i am very happy with them than from my previous web host provider.
This post tutorial guide will show you how to retrieve, get, show, display, find your weg page (site) visitors screen resolution.
NOTE: for this function to work, you will need to have PHP, if you don't have PHP on your website, we recommend our friends at www.webune.com for PHP hosting. check them out.
the first thing to do is to copy and past this sample code into your editor, you can use notepad it you like:
CODE:
<HTML>
<TITLE>Getting User's Screen Resolutions with PHP Script Code Sample Example</TITLE>
<HEAD>
<?
if(isset($HTTP_COOKIE_VARS["users_resolution"]))
$screen_resolution = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2010");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
location = 'show-user-screen-resolution-php.php';
}
//-->
</script>
<?
}
?>
</HEAD>
<style type="text/css">
<!--
.style1 {color: #0000FF}
.style2 {color: #0066FF}
.style3 {color: #CC0000}
-->
</style>
<BODY>
<h1 align="center" class="style2"><strong>Your Screen Resolutions is set to:</strong> <?php echo $screen_resolution; ?></h1>
<div align="center">Turotial by <a href="http://www.wallpaperama.com">Wallpaperama.com</a></div>
<hr size="2" noshade>
<p>Hello and Welcome to this Wallpaperama "Get User's Screen Resolution" Script.</p>
<p>As webmaster, we often need to get the user's screen resolution to make our visitor's expirience more enjoyable and fun.</p>
<p>One way wallpaperama has implemented this, is to customize specific webpages to our visitors depending on the computer screen resolution
setting or properties.</p>
<p>The PHP function to do this is: <span class="style1">isset</span>(<span class="style2">$HTTP_COOKIE_VARS</span>[<span
class="style3">"users_resolution"</span>])</p>
<p><a href="http://www.wallpaperama.com/"><< Go Back</a> </p>
<p align="center">PHP Hosting by <a href="http://www.webune.com">Webune.com</a> </p>
<p>
</BODY>
</HTML>
<TITLE>Getting User's Screen Resolutions with PHP Script Code Sample Example</TITLE>
<HEAD>
<?
if(isset($HTTP_COOKIE_VARS["users_resolution"]))
$screen_resolution = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2010");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
location = 'show-user-screen-resolution-php.php';
}
//-->
</script>
<?
}
?>
</HEAD>
<style type="text/css">
<!--
.style1 {color: #0000FF}
.style2 {color: #0066FF}
.style3 {color: #CC0000}
-->
</style>
<BODY>
<h1 align="center" class="style2"><strong>Your Screen Resolutions is set to:</strong> <?php echo $screen_resolution; ?></h1>
<div align="center">Turotial by <a href="http://www.wallpaperama.com">Wallpaperama.com</a></div>
<hr size="2" noshade>
<p>Hello and Welcome to this Wallpaperama "Get User's Screen Resolution" Script.</p>
<p>As webmaster, we often need to get the user's screen resolution to make our visitor's expirience more enjoyable and fun.</p>
<p>One way wallpaperama has implemented this, is to customize specific webpages to our visitors depending on the computer screen resolution
setting or properties.</p>
<p>The PHP function to do this is: <span class="style1">isset</span>(<span class="style2">$HTTP_COOKIE_VARS</span>[<span
class="style3">"users_resolution"</span>])</p>
<p><a href="http://www.wallpaperama.com/"><< Go Back</a> </p>
<p align="center">PHP Hosting by <a href="http://www.webune.com">Webune.com</a> </p>
<p>
</BODY>
</HTML>
now save it as show-user-screen-resolution-php.php and upload it to your website.
after you have uploaded to your website, open the file with your browser (example: yourdomain.com/show-user-screen-resolution-php.php)
after you have opened it, you will see your own screen resolution display on the screen.
Our friends at www.webune.com have provided us with free hosting to demonstrate how this script works.
NOTE: you will require to be hosted on a site that has PHP. If you need PHP web hosting, www.webune.com has great PHP packages available, I recommend them cuz i am very happy with them than from my previous web host provider.
uLtrasix Fri Feb 26, 2010
yo i wanted to know if a user computer must have javascript enabled? I noticed there was JS code present so... I know its highly unlikely but user's who have it disabled this wont work...
wallpaperama Wed Oct 28, 2009
it sounds like you dont have php on your site
amit Wed Oct 28, 2009
hello sir,
when i add this code in my php page not working,but when i change file extension to .html then i add ur source code it works.can u help me to slove this issue.
when i add this code in my php page not working,but when i change file extension to .html then i add ur source code it works.can u help me to slove this issue.
monali Sat Mar 07, 2009
how to find the resolution is understood but problem is how to set my form resolution to resolution of the computer on which it is running
Mark Tue Feb 03, 2009
close, but no cigar.
this claims to be a "way to find a user's screen resolution with php," but is actually a way to find a user's screen resolution with javascript and pass it to php via a cookie.
the problem is, much of the time a developer would be looking to find out how to find a user's screen resolution with php, it's because he is trying to write something that will work for user's who keep javascript turned off for security reasons.
thus, since this proposed solution relies upon javascript, and not just php, it's of limited value in those situations.
this claims to be a "way to find a user's screen resolution with php," but is actually a way to find a user's screen resolution with javascript and pass it to php via a cookie.
the problem is, much of the time a developer would be looking to find out how to find a user's screen resolution with php, it's because he is trying to write something that will work for user's who keep javascript turned off for security reasons.
thus, since this proposed solution relies upon javascript, and not just php, it's of limited value in those situations.
vss Sun Nov 09, 2008
two .php extensions in the script
Joe Tue Sep 09, 2008
when i tried opening file on my website and your demo it adds php to the address and says "the page cannot be found"
Carl Sun Jan 27, 2008
link doesn't work.
Related Content
Information
Forums »
PHP Forums And Topics Discussions About Hyper Text Programming Language »
Php Tutorial Guide - How To Show Screen Resolution Find Display Script
PHP Forums And Topics Discussions About Hyper Text Programming Language »
Php Tutorial Guide - How To Show Screen Resolution Find Display Script
Title: Php Tutorial Guide - How To Show Screen Resolution Find Display Script
Description: Php Tutorial Guide - How To Show Screen Resolution Find Display Script
Tags: php ,tutorial ,guide ,how ,to ,show ,screen ,resolution ,find ,display ,script
Info: This Post Has Been Viewed 0 Times Since
Date: Wed Nov 29, 2006
Author leni Received 8 Replies #977
Date: Wed Nov 29, 2006
Author leni Received 8 Replies #977
Share
URL: 

Embed: 

To embed this topic, just copy the code from the "Embed" box. Once you've copied the code, just paste it into your website or blog to embed it
BBCODE:: 

BBCODE is use on forums. You can put this code on all your BBCODE enabled forums like PhpBB, vBulletin® and others. Just Copy and Paste this code on your Posts and Replies on your forums
wallpaperama | Wallpapers | Forums | Terms Of Service
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5
copyright © 2013 wallpaperama - All Rights Reserved - Last Updated Mon May 06, 2013 (-8 GMT)
Powered by: Webune Forums V5