Skip to content

Commit

Permalink
MySQL now inserts name
Browse files Browse the repository at this point in the history
  • Loading branch information
otakaran committed Jan 27, 2017
1 parent 766ae88 commit 6b8db80
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
</style>

<?php
// Include Password File
include 'password.php';

// define variables and set to empty values
$nameErr = $emailErr = $genderErr = $websiteErr = "";
$name = $email = $gender = $comment = $website = "";
Expand Down Expand Up @@ -207,10 +210,11 @@ function sst_close() {

echo "<h2>Your Input:</h2>";
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
Expand All @@ -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";
Expand Down
47 changes: 47 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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));

0 comments on commit 6b8db80

Please sign in to comment.