connect_error)
{
exit("Connection failed: " . $conn->connect_error);
}
if(isset($_GET['check'])) //if check is in the URL then the Athlete has hit submit
{
$physical = $_POST['physical']; //physical score from the survey
$academic = $_POST['academic']; //academic score from the survey
$perform = $_POST['perform']; //performace score from the survey
$relation = $_POST['relation']; //relationship score from the survey
$sleep = $_POST['sleep']; //hours slept from the survey
$meeting = $_POST['meeting']; //meeting value from the survey
$id = $_POST['id']; //id from the survey
$id = strtolower($id); //make sure its lowercase
$id = trim($id); //trim any spaces from the id
//Query to see if they are in the Athlete_Info table
$query = "SELECT * FROM Athlete_Info WHERE A_ID = '{$id}'";
$result = $conn->query($query);
if($result->num_rows == 0) //check to see if the survey has been filled out.
{
//echo ''; //alert the athlete to fill out the page, then loads the survey again
//the athlete isn't registered and the register page will be loaded
header("Location: register.php?player=".$id);
//header("Location: athlete_survey.php?thank=1");
}
else
{
$today = date("Ymd"); //todays date
//Query to insert the data into the database
//Test_Data uses ID and has the sample data. Athlete_Data uses A_ID and has the real data
$query = "INSERT INTO Test_Data (ID, Date, physical, academic, perform, relation, sleep, meeting) VALUES ('{$id}','{$today}','{$physical}', '{$academic}', '{$perform}', '{$relation}', '{$sleep}','{$meeting}')"; //'{$physical}', '{$academic}', '{$perform}', '{$relation}', '{$sleep}','{$meeting}'
//Send the data
if($conn->query($query) === TRUE)//if the data is sent
{
header("Location: athlete_survey.php?thank=1");
}
else
{
//an error has occured
echo "ERROR: " . $conn . "
" .$conn->error;
echo "Please contact your coach if this error persists. ";
echo "