Yeti-Robotics / angular-scouting

FIRST Scouting web app from Yeti Robotics
4 stars 3 forks source link

Instructions for use? #18

Closed FlamingSpork closed 8 years ago

FlamingSpork commented 8 years ago

Hello! I'm from team 3003, and I'm trying to use your scouting system. I have edited the config file:

<?php
// database connection variables
$dbserver = "localhost";
$dbuser = "root";
$dbpassword = "root";
$dbname = "scouting";

// FMSAPI variables
$tournamentKey = "NYRO";
$tournamentYear = 2016;
$authUser = "user"; //Still waiting on key
$authToken = "token";
$apiServer = "https://frc-api.firstinspires.org/v2.0";

// Admin Account details
$adminUsername = "aadmin";
$adminPswdHash = "5f4dcc3b5aa765d61d8327deb882cf99"; // It's "password"
?>

Even though I created the scouting database, it it completely empty:

mysql> SHOW TABLES IN scouting;
Empty set (0.00 sec)

Whenever I try to login (either with admin or an account I just created) it fails.

antoinecampbell commented 8 years ago

The DB schema is in a file that must be imported first, /sql/scouting_structure.2016.sql. @samperlmutter and @wazateer1 can give you a hand if you need more assistance. The database should be completely empty.

antoinecampbell commented 8 years ago

Once you start submitting some scouting forms you will have some data. Not sure if what you meant by empty was the lack of data or the lack of tables.

FlamingSpork commented 8 years ago

I've imported the structure, but now it doesn't let me log in either with the admin user or a user I created.

antoinecampbell commented 8 years ago

You shouldn't need to log in to scout @wazateer1 and @samperlmutter can help you with the wagering madness that was added on.

ghost commented 8 years ago

Hey FlamingSpork, thanks for trying out our Scouting System! Did you make the accounts after you imported the structure? This is important. I see you have direct access to your SQL server, try "SELECT * FROM scouters" to see if the accounts are in your SQL database.

Also, as a way of making the admin account customizable, it must be created first by registering it. This way it may have whatever name you want, but to make sure that not anyone can create the admin account the account must be created with the password "password", or whatever will md5hash into $adminPswsHash

FlamingSpork commented 8 years ago

I tried creating some accounts after importing the structure, but it still says that they are invalid. I did create the admin account as you suggested, but it doesn't allow me to log in to it.

ghost commented 8 years ago

Huh, that sounds odd. Maybe the php scripts ar enot running properly? If you are using a browser with developer options, try viewing the requests your browser is making. On google chrome it's Ctrl+Shift+J and then the Network tab. Once you click login on the login page it should show a request to checkUser.php. By clicking that request and then clicking the response option you can see what kind of data the php script is sending back.

FlamingSpork commented 8 years ago

The login fails with a error 500. This is what the console says:

POST http://localhost/angular/php/checkUser.php 500 (Internal Server Error)
(anonymous function) @ angular.js:10661
q @ angular.js:10480
g @ angular.js:10187
(anonymous function) @ angular.js:14634
n.$eval @ angular.js:15916
n.$digest @ angular.js:15727
n.$apply @ angular.js:16024
(anonymous function) @ angular.js:23416
n.event.dispatch @ jquery-2.1.4.min.js:3
r.handle @ jquery-2.1.4.min.js:3
ghost commented 8 years ago

If the php is returning an error, it may be contained in what the server actually returns. Can you go to the Network tab and see the actual text it is returning?

FlamingSpork commented 8 years ago

Chrome says This request has no response data available. Request details:

Request URL:http://localhost/angular/php/checkUser.php
Request Method:POST
Status Code:500 Internal Server Error
Remote Address:127.0.0.1:80

Response Headers
HTTP/1.0 500 Internal Server Error
Date: Sun, 17 Apr 2016 13:05:40 GMT
Server: Apache/2.4.7 (Ubuntu)
X-Powered-By: PHP/5.5.9-1ubuntu4.14
Content-Length: 0
Connection: close
Content-Type: text/html

Request Headers
POST /angular/php/checkUser.php HTTP/1.1
Host: localhost
Connection: keep-alive
Content-Length: 35
Pragma: no-cache
Cache-Control: no-cache
Accept: application/json, text/plain, */*
Origin: http://localhost
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36
Content-Type: application/json;charset=UTF-8
Referer: http://localhost/angular/
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.8,es-419;q=0.6,es;q=0.4,en-GB;q=0.2

Request Payload
{"username":"spork","pswd":"spork"}

Firefox also reports an empty response.

ghost commented 8 years ago

Now that is odd. When we report an error in our own code, the first response header is usually a 500 SQL Error. Does your PHP error log report anything?

FlamingSpork commented 8 years ago

Apache reports a PHP error:

[Sun Apr 17 10:06:12.213706 2016] [:error] [pid 5338] [client 127.0.0.1:33607] PHP Fatal error:  Call to undefined method mysqli_stmt::get_result() in /var/www/html/angular/php/functions.php on line 423, referer: http://localhost/angular/

A quick search seems to suggest that I need to install some Apache/PHP modules.

FlamingSpork commented 8 years ago

It works (or at least allows me to log in)! I needed to install php5-mysqlnd and enable it in php.ini. Thanks for your help!