Exemple #1
0
<?php

session_start();
require './shared_methods_and_data.php';
$_SESSION['user_name'] = generate_user_name(get_current_user_ip());
$_SESSION['current_question'] = "";
$result = mysql_fetch_array(search_sql_table($results_table, "user_name", $_SESSION['user_name']));
if ($result['0'] == NULL) {
    create_user($_SESSION['user_name']);
}
$_SESSION['last_answer'] = "You haven't answered any questions yet...";
?>

<html>
	<head>
            <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
	</head>
	<body>
	<h1>Short description</h1>
	<a href="select_question.php"> Start the game</a>
	</body>
</html>
function copy_question_like($term)
{
    //Import variables
    global $sql_user_name;
    global $sql_password;
    global $db_name;
    global $results_table;
    global $questions_table;
    global $init_result;
    global $question_validity_time;
    global $points_per_question;
    global $questions_bank;
    $result = search_sql_table($questions_bank, 'question', $term);
    $sql_connection = mysql_connect("localhost", $sql_user_name, $sql_password);
    if (!$sql_connection) {
        die("MySQL error :" . mysql_error());
    }
    //DEBUGGING CODE : Attempt to create Database and table and ignore all errors
    mysql_query("CREATE DATABASE " . $db_name, $sql_connection);
    //Select the database that we will be working with
    mysql_select_db($db_name, $sql_connection);
    //DEBUGGING CODE : Attempt to create the Table and ignore all errors
    mysql_query("CREATE TABLE " . $questions_bank . "(question_id int NOT NULL AUTO_INCREMENT,PRIMARY KEY(question_id),question varchar(255),choice_1 varchar(255),choice_2 varchar(255),choice_3 varchar(255),correct_choice varchar(255),start_time varchar(255))", $sql_connection);
    mysql_query("CREATE TABLE " . $questions_table . "(question_id int NOT NULL AUTO_INCREMENT,PRIMARY KEY(question_id),question varchar(255),choice_1 varchar(255),choice_2 varchar(255),choice_3 varchar(255),correct_choice varchar(255),start_time varchar(255))", $sql_connection);
    //END DEBUG CODE
    if (!$result) {
        echo "No questions Available From that Catagory";
        return;
    }
    $row = mysql_fetch_array($result);
    if ($row['question'] == '') {
        echo "No questions Available From that Catagory";
        return;
    }
    mysql_query("INSERT INTO " . $questions_table . " VALUES (NULL,\"" . $row['question'] . " \",\"" . $row['choice_1'] . "\",\"" . $row['choice_2'] . "\",\"" . $row['choice_3'] . "\",\"" . $row['correct_choice'] . "\",\"" . (time() + 10) . "\")", $sql_connection);
    //DEBUG CODE
    echo "Question '" . $row['question'] . "' with the correct answer '" . $row['correct_choice'] . "' inserted";
    update_sql_table($questions_bank, 'question', $row['question'], 'question', '');
    return;
}