"; // Let's create the menu print "
"; print ""; print ""; print ""; print "
"; print "Welcome, $first_name!

"; print "This is a filler page for the main menu. Various options will appear here. Including
- The option to change account settings (e.g., email, notifications)
- The option to take surveys
- The option to see results from surveys already taken

"; // Set the database access information as constants: DEFINE ('DB_USER', 'rcfraley'); DEFINE ('DB_PASSWORD', '*PASSWORD*'); DEFINE ('DB_HOST', 'yourpersonality.netfirmsmysql.com'); DEFINE ('DB_NAME', 'ullman'); // Make the database connection: $dbc = @mysqli_connect (DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die ('Could not connect to MySQL: ' . mysqli_connect_error() ); // Define a SQL query // Here we are selecting the stored password and user_id for rows where // the database email (email) and submitted email($e) match one another. // v2.0 We are also selecting the status variables for the studies associated // with this menu. $q = "SELECT study1_taken, study1_lastdate, study1_type, study2_taken, study2_lastdate, study2_type, study3_taken, study3_lastdate, study3_type FROM users WHERE user_id='$user_id' AND session='$tempID'"; $r = @mysqli_query ($dbc, $q); // Run the query. if ($r) { // If it ran OK. $num = mysqli_num_rows($r); }else{ $error[] = "Error querring the database. Please contact the site administrator."; } // Let's place query results in an array called $results // moood_survey will be [0] and study2_taken will be element [1] etc $results = mysqli_fetch_array($r, MYSQLI_BOTH); /* ----------------------------------------------------------------- To help organize the menu options better, I will present the survey choices in a table. A table within a table. This is kind of old school, but let's hope old school makes a come back one day. I've updated the CSS file to contain special styles for id = menurows This will allow us to assign every other row to the class=alt so we can alternate the background colors of the table rows for easier reading. (It is easier on the eyes--if you're old [I mean old school].) ----------------------------------------------------------------- */ print "
"; print ""; print ""; print ""; // Survey 1 // Take once print ""; print ""; // Note: If 'study1_taken' does not exist, present a "take survey" option. // If it does exist (it is >=1), print a completion message. print ""; // Note: If 'study1_taken' does not exist, do not provide an option // to see the results. We print nothing. // If it does exist (it is >=1), we provide an option to see results. print ""; print ""; // Survey 2 // Repeated measures print ""; print ""; // Note: In contrast to the study above, it is okay for people // to take survey2 repeatedly. Thus, we always present the // Take Survey option, regardless of the status of study2_taken. // (We could have done without the conditionals here. But I was // copying-and-pasting and it is nice to see the logical structure, // even if both options lead to the same outcomes. print ""; // Note: If 'study2_taken' does not exist, do not provide an option // to see the results. We print nothing. // If it does exist (it is >=1), we provide an option to see results. print ""; print ""; // Survey 3 // doesn't exist print ""; print ""; // Note: If 'study3_taken' does not exist, present a "take survey" option. // If it does exist (it is >=1), print a completion message. print ""; // Note: If 'study3_taken' does not exist, do not provide an option // to see the results. We print nothing. // If it does exist (it is >=1), we provide an option to see results. print ""; print ""; print "
Survey"; print " Status"; print " Results"; print "
"; print "Surveydemo1"; print ""; if(!$results['study1_taken']){ print " Take Survey"; } if($results['study1_taken']>=1){ print "Completed"; } print ""; if(!$results['study1_taken']){ print "  "; } if($results['study1_taken']>=1){ print " See Results"; } print "
"; print "Your emotional states"; print ""; if(!$results['study2_taken']){ print " Take Survey"; } if($results['study2_taken']>=1){ print " Take Survey"; } print ""; if(!$results['study2_taken']){ print "  "; } if($results['study2_taken']>=1){ print " See Results"; } print "
"; print "Attachment Styles"; print ""; if(!$results['study3_taken']){ print " Take Survey"; } if($results['study3_taken']>=1){ print " Take Survey"; } print ""; if(!$results['study3_taken']){ print "  "; } if($results['study3_taken']>=1){ print " See Results"; } print "
"; print "
"; print "
"; print "
Log out "; print " Change password "; print "
"; // Close the database connection. mysqli_close($dbc); ?>