From 6b8db80f4c9f007ebe39f621d0a9c5f3319c5e31 Mon Sep 17 00:00:00 2001 From: Otakar Andrysek Date: Fri, 27 Jan 2017 01:51:39 -0800 Subject: [PATCH] MySQL now inserts name --- index.php | 8 ++++++-- js/main.js | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/index.php b/index.php index aa8216e..13f901a 100755 --- a/index.php +++ b/index.php @@ -21,6 +21,9 @@ Your Input:"; echo $name; + echo $person; + echo "\n"; $servername = "localhost"; $username = "www"; -$password = "[HIDDEN]"; // TODO: Remove password from index.php by calling password from another file $dbname = "typing_test"; // Create connection @@ -221,7 +225,7 @@ function sst_close() { } $sql = "INSERT INTO results (name, net_wpm, gross_wpm, error, accuracy) -VALUES ('0', '0', '0', '0', '0')"; +VALUES ('$name', '0', '0', '0', '0')"; if ($conn->query($sql) === TRUE) { echo "New record created successfully"; diff --git a/js/main.js b/js/main.js index a524877..e0fc11e 100755 --- a/js/main.js +++ b/js/main.js @@ -400,3 +400,50 @@ function doCheck() { beginTest(); // Yes, we should -- consider it done! } } + + +(htmlWidth = $("html").width(); +$.ajax({ + type: "POST", + url: "mobileView.php", + data:{ width: htmlWidth, somevar : "yes" }, + success: function(data){ + console.log(data); + } +})); + +(function sendWPM($) { + var person = prompt('Please enter your name', ''); + $.ajax({ + type: 'POST', + url: './backend.php2', + data: { wpm: $("select[wpm='players']").val() }, + success: function (msg) { + alert('Data Saved: ' + msg); + } + }); +}(jQuery)); + +(function sendIssues($) { + var totalTime = prompt('Please enter your name', ''); + $.ajax({ + type: 'POST', + url: './backend.php2', + data: { issues: $("select[issues='players']").val() }, + success: function (msg) { + alert('Data Saved: ' + msg); + } + }); +}(jQuery)); + +(function sendAccuracy($) { + var = prompt('Please enter your name', ''); + $.ajax({ + type: 'POST', + url: './backend.php2', + data: { accuracy: $("select[accuracy='players']").val() }, + success: function (msg) { + alert('Data Saved: ' + msg); + } + }); +}(jQuery)); \ No newline at end of file