<?php

require_once "C:\\wamp\\www\\QuickTrail/Controller/DbConnection.php";
$db = new DbConnection_Controller();
ini_set("odbc.defaultlrl", "100000K");
if (isset($_GET["id"])) {
    $sql = "select Fb_Photo from tblQuickTrail where pkTrailID='" . $_GET["id"] . "'";
    if ($db->StartDbConnection()) {
        $row = odbc_exec($db->GetCon(), $sql);
        odbc_fetch_row($row);
        header("Content-Type: image/jpeg");
        $img = odbc_result($row, "Fb_Photo");
        echo $img;
        odbc_free_result($row);
    }
}
?>
  
 
?>
</head>
<body class="ui-content">
	<div class="ui-content ui-body-m">
		<img src='trailapp.png' alt='trail app'><small>by Vincent Nacar</small>
	</div>
	<center>
	<div>
		<?php 
if (isset($_POST["submit-index"])) {
    header("Location:Index.php");
}
if (isset($_POST["submit-registration"])) {
    require_once "Controller/DbConnection.php";
    require_once "Controller/CreateAccount.php";
    $db = new DbConnection_Controller();
    $newAcct = new CreateAccount($_POST["email"]);
    if ($db->StartDbConnection()) {
        if (!$newAcct->CheckEmailIfExists($db->GetCon())) {
            $newAcct->GetUserData($_POST["fullname"], $_POST["sex"], $_POST["bday"], $_POST["pass"]);
            if ($newAcct->SaveNewAccount($db->GetCon())) {
                echo "success";
            }
        } else {
            echo "Email is currently used by another user.";
        }
    }
}
?>
		<h3>Create an Account</h3><hr>
		<form action="CreateAccount.php" method="POST">
<?php

if (isset($_GET["id"])) {
    //session_start();
    require_once "C:\\wamp\\www\\QuickTrail/Controller/DbConnection.php";
    $db = new DbConnection_Controller();
    if ($db->StartDbConnection()) {
        $query = "Select pkCommentID,fk_MemberID,fcName,fcComment,fcDate\n\t\t\t\t\t\tfrom tblQuickComment where fkTrailID='" . $_GET["id"] . "'\n\t\t\t\t\t\torder by pkCommentID desc";
        $rows = odbc_exec($db->GetCon(), $query);
        while (odbc_fetch_row($rows)) {
            $commentID = odbc_result($rows, "pkCommentID");
            $userID = odbc_result($rows, "fk_MemberID");
            $name = odbc_result($rows, "fcName");
            $comment = odbc_result($rows, "fcComment");
            $date = odbc_result($rows, "fcDate");
            echo "\n\t\t\t\t\t<div class='ui-content' id='" . $commentID . "' style='background-color:white;'>\n\t\t\t\t\t\t<table>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td><b style='color:teal;'>" . $name . "</b></td>\n\t\t\t\t\t\t\t\t<td><small style='color:gray;'>says</small></td>\n\t\t\t\t\t\t\t\t<td>" . $comment . "</td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t<td colspan='4'><small style='color:gray;'>" . $date . "</small></td>\n\t\t\t\t\t\t\t</tr>\n\t\t\t\t\t\t</table>\n\t\t\t\t\t</div>\n\t\t\t\t\t\t";
        }
    }
}