Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed the PHP Outputting 'Undefined Index' Issue #27

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CrookedStyleSheets
Submodule CrookedStyleSheets added at e93f3a
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

<!DOCTYPE html>
<html lang="en">
<head>
Expand Down
150 changes: 133 additions & 17 deletions results.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,119 @@
<?php
session_start();

/* Just to prevent the PHP output, we
give every variable a default value.
*/
$started = "false";
$device = "unknown";
$link1_clicked = "false";
$link2_clicked = "false";
$link3_clicked = "false";
$s1_hovered = "false";
$s2_hovered = "false";
$s3_hovered = "false";
$s4_hovered = "false";
$duration = 0;
$text_input = "false";
$checkbox = "false";
$browser_chrome = "false";
$browser_firefox = "false";
$browser_edge = "false";
$orientation = "unknown";
$width = "unknown";
$height = "unknown";

if( isset($_SESSION["started"]) ){

$started = $_SESSION["started"];
}

if( isset($_SESSION["device"]) ){

$device = $_SESSION["device"];
}

if( isset($_SESSION["link1_clicked"]) ){

$link1_clicked = $_SESSION["link1_clicked"];
}

if( isset($_SESSION["link2_clicked"]) ){

$link2_clicked = $_SESSION["link2_clicked"];
}

if( isset($_SESSION["link3_clicked"]) ){

$link3_clicked = $_SESSION["link3_clicked"];
}

if( isset($_SESSION["s1_hovered"]) ){

$s1_hovered = $_SESSION["s1_hovered"];
}

if( isset($_SESSION["s2_hovered"]) ){

$s2_hovered = $_SESSION["s2_hovered"];
}

if( isset($_SESSION["s3_hovered"]) ){

$s3_hovered = $_SESSION["s3_hovered"];
}

if( isset($_SESSION["s4_hovered"]) ){

$s4_hovered = $_SESSION["s4_hovered"];
}

if( isset($_SESSION["duration"]) ){

$duration = $_SESSION["duration"];
}

if( isset($_SESSION["text_input"]) ){

$text_input = $_SESSION["text_input"];
}

if( isset($_SESSION["checkbox"]) ){

$checkbox = $_SESSION["checkbox"];
}

if( isset($_SESSION["browser_chrome"]) ){

$browser_chrome = $_SESSION["browser_chrome"];
}

if( isset($_SESSION["browser_firefox"]) ){

$browser_firefox = $_SESSION["browser_firefox"];
}

if( isset($_SESSION["browser_edge"]) ){

$browser_edge = $_SESSION["browser_edge"];
}


if( isset($_SESSION["orientation"]) ){

$orientation = $_SESSION["orientation"];
}

if( isset($_SESSION["width"]) ){

$width = $_SESSION["width"];
}

if( isset($_SESSION["height"]) ){

$height = $_SESSION["height"];
}

?>

<!DOCTYPE html>
Expand All @@ -19,29 +133,31 @@
<h1>Results</h1>
<b>When the value is empty or PHP notices appears, it means that the value is false or the webpage hasn't been visited yet.</b>
<ul>
<li>Last visited: <b><?php print $_SESSION["started"]?></b></li>
<li>Device Type: <b><?php print $_SESSION["device"]?></b></li>
<li>Link1 (google.de) clicked: <b><?php print $_SESSION["link1_clicked"] ?></b></li>
<li>Link2 (foo.bar) clicked: <b><?php print $_SESSION["link2_clicked"]?></b></li>
<li>Link3 (github.com) clicked: <b><?php print $_SESSION["link3_clicked"]?></b></li>
<li>Last visited: <b><?php print $started;?></b></li>
<li>Device Type: <b><?php print $device;?></b></li>
<li>Link1 (google.de) clicked: <b><?php print $link1_clicked;?></b></li>
<li>Link2 (foo.bar) clicked: <b><?php print $link2_clicked;?></b></li>
<li>Link3 (github.com) clicked: <b><?php print $link3_clicked;?></b></li>
<li></li>
<li>Field 1 hovered: <b><?php print $_SESSION["s1_hovered"]?></b></li>
<li>Field 2 hovered: <b><?php print $_SESSION["s2_hovered"]?></b></li>
<li>Field 3 hovered: <b><?php print $_SESSION["s3_hovered"]?></b></li>
<li>Field 4 hovered: <b><?php print $_SESSION["s4_hovered"]?></b></li>
<li>Field 1 hovered: <b><?php print $s1_hovered;?></b></li>
<li>Field 2 hovered: <b><?php print $s2_hovered;?></b></li>
<li>Field 3 hovered: <b><?php print $s3_hovered;?>

</b></li>
<li>Field 4 hovered: <b><?php print $s4_hovered;?></b></li>
<li></li>
<li>Duration field was hovered for at least <b> <?php print $_SESSION["duration"] / 10?></b> seconds (raw value: <?php print $_SESSION["duration"]?>) [approx. 1s resolution]
<li>Duration field was hovered for at least <b> <?php print $duration / 10?></b> seconds (raw value: <?php $duration?>) [approx. 1s resolution]
<li></li>
<li>"test" was typed into input box: <b><?php print $_SESSION["text_input"]?></b></li>
<li>Checkbox was checked: <b><?php print $_SESSION["checkbox"]?></b></li>
<li>"test" was typed into input box: <b><?php print $text_input?></b></li>
<li>Checkbox was checked: <b><?php print $checkbox?></b></li>
<li></li>
<li>Calibri font existing: <b><?php isset($_SESSION["font1"]) ? print $_SESSION["font1"] : print true?></b></li>
<li></li>
<li>Browser Chrome: <b><?php print $_SESSION['browser_chrome']?></b></li>
<li>Browser Firefox: <b><?php print $_SESSION['browser_firefox']?></b></li>
<li>Browser Edge: <b><?php print $_SESSION['browser_edge']?></b></li>
<li>Orientation: <b><?php print $_SESSION['orientation']?></b></li>
<li>Resolution: <b><?php print $_SESSION['width']?>x<?php print $_SESSION['height']?></b> (only often used widths are supported, your screen resolution is greater than or equal to shown resolution.)</li>
<li>Browser Chrome: <b><?php print $browser_chrome?></b></li>
<li>Browser Firefox: <b><?php print $browser_firefox?></b></li>
<li>Browser Edge: <b><?php print $browser_edge?></b></li>
<li>Orientation: <b><?php print $orientation?></b></li>
<li>Resolution: <b><?php print $width?> x <?php print $height?></b> (only often used widths are supported, your screen resolution is greater than or equal to shown resolution.)</li>
</ul>
</div>

Expand Down
9 changes: 9 additions & 0 deletions screen.css
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,15 @@
}
}


@media( min-device-width: 1200px){

#width::after{

content: url("track.php?width=1200")
}
}

@media (min-device-width: 1280px) {
#width::after {
content: url("track.php?width=1280");
Expand Down
25 changes: 25 additions & 0 deletions track.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,30 @@
<?php
session_start();

/*Need to check if isset before adding defaults
if we don't it resets the values.*/

/*
$_SESSION['orientation'] = "unknown";
$_SESSION['width'] = "unknown";
$_SESSION['height'] = "unknown";
$_SESSION['duration'] = 0;
$_SESSION["device"] = "unknown";
$_SESSION["link1_clicked"] = "false";
$_SESSION["link2_clicked"] = "false";
$_SESSION["link3_clicked"] = "false";
$_SESSION["s1_hovered"] = "false";
$_SESSION["s2_hovered"] = "false";
$_SESSION["s3_hovered"] = "false";
$_SESSION["s4_hovered"] = "false";
$_SESSION["browser_chrome"] = "false";
$_SESSION["browser_firefox"] = "false";
$_SESSION["browser_edge"] = "false";
$_SESSION["text_input"] = "false";
$_SESSION["checkbox"] = "false";
$_SESSION["last_visit"] = "unknown";
*/

$action = $_REQUEST['action'];

if(!empty($_REQUEST['orientation']))
Expand All @@ -15,6 +39,7 @@
if(!empty($_REQUEST['duration']))
$_SESSION['duration'] = $_REQUEST['duration'];


switch($action)
{
case "screen_start":
Expand Down