Jump to content

mitch3893

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

mitch3893's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hey guys, What im trying to do is get the users screen resolution and place it into a database so that i can call it up and place it onto a stats page. So far i get the idea that you have to use Javascript to get the resolution then use PHP to pull that information. What i want to do is pull the screen resolutions and place them into a database so that i can call upon them to place into a stats page So far i have the following getting certain bits of information and banging them into the database using the stats.inc.php then calling them up and placing them onto stats.php. the stats.inc.php is included on every page of my site so it can track where a users has been etc etc. Im assuming i can insert something into my headerLoggedin.inc.php file that will pull the users resolution then use some PHP in the stats.inc.php script to pull that information and then insert it into my database which i can then easily pull from and place into the stats.php page. I know this seems like a bit of a silly thing to be doing, its for a college assignment and im pretty stumped. Any help is appreciated thanks guys. headerLoggedin.php <?php include('includes/security.inc.php'); ?> <?php include('includes/stats.inc.php');?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Language" content="en-us" /> <link rel="stylesheet" href="css/index.css" type="text/css"/> <title>############</title> </head> <body> <!-- Start of wrapper div--> <div id="wrapper"> <!-- Start of header div--> <div id="header"> <div id="logo"><img src="./images/logo.png" width="412" height="32" alt="Elite Recruitment Services" /></div> <div id="navigation"> <ul class="nav"> <li><a href="news.php">News Page</a></li> <li><a href="edit.php">Edit text file</a></li> <li><a href="upload.php">Upload text file</a></li> <li><a href="stats.php">Stats</a></li> <li><a href="logout.php">Logout</a></li> </ul> </div> </div> <!--End of header div--> <!--Start of loginContainer div--> <div id="formsContainer"> stats.inc.php <?php $db_host = "localhost"; // Databases host name $db_username ="#######"; // Database Username $db_password ="#######"; // Database Password $db_name ="dannymit_stats"; // Databases name $db_table="statTracker"; // Database table where the logins are stored mysql_connect("$db_host", "$db_username", "$db_password"); // Connects to the database using the preset host, username and password mysql_select_db("$db_name"); // Selects the database. //collect information... $browser = $_SERVER['HTTP_USER_AGENT']; // get the browser name $curr_page = $_SERVER['PHP_SELF'];// get page name $ip = $_SERVER['REMOTE_ADDR']; // get the IP address $from_page = $_SERVER['HTTP_REFERER'];// page from which visitor came $page = $_SERVER['PHP_SELF'];//get current page $width = $_GET['width']; //Gets users screen width $height = $_GET[['height']; //Gets users screen height //Insert the data in the table... $query_insert = "INSERT INTO statTracker (browser,ip,thedate_visited,page,from_page) VALUES ('$browser','$ip',now(),'$page','$from_page')" ; $result=mysql_query ( $query_insert); if(!$result){ die(mysql_error()); } ?> stats.php <?php // Header include include('includes/headerLoggedin.inc.php'); include('includes/stats.inc.php'); ?> <br/><br/> <?php $db_host = "localhost"; // Databases host name $db_username ="######"; // Database Username $db_password ="######"; // Database Password $db_name ="dannymit_stats"; // Databases name $db_table="statTracker"; // Database table where the logins are stored mysql_connect("$db_host", "$db_username", "$db_password"); // Connects to the database using the preset host, username and password mysql_select_db("$db_name"); // Selects the database. $sqlquery = "SELECT * FROM `$db_table`"; $result = mysql_query($sqlquery); $num = mysql_num_rows($result); mysql_close(); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { printf ("Browser:<br/> %s<br/> IP Address:<br/> %s<br/> Date Visited:<br/> %s<br/> Page Visited:<br/> %s<br/> Paged Visited From:<br/> %s<br/>", $row[1], $row[2], $row[3], $row[4], $row[5]); echo "<br />"; } ?> <?php include('includes/footer.inc.php');?>
  2. Thats great thanks a lot (I dont quite understand it all yet but will try to get my head around it)
  3. Hi, I have recently been to an interview for a Junior PHP developer position and everything was going well until i was asked to do a task. The task was as follows, Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”. I could do the basic loop to print out the numbers but couldn't work out a way to single out the multiples of 3 and 5 and where the multiples were both 3 and 5. Any help would be appreciated. Thanks Dan
×
×
  • 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.