<?php

session_start();
if (isset($_GET['id'])) {
    include "dbconnection.php";
    $puzzle_id = $_GET['id'];
    $rhyme_details = getPuzzleById($_GET['id']);
    $puzzle = mysql_fetch_array($rhyme_details);
} else {
    header("location:kid-puzzles-games");
}
?>
<!doctype html>
<html lang="en">
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<meta content="<?php 
echo $puzzle['meta_tag_keyword'];
?>
" name="keywords"  />
<meta content="<?php 
echo $puzzle['meta_tag_description'];
?>
" name="description"/>
<meta name="robots" content="noindex">
<title><?php 
echo $puzzle['puzzle_title'];
?>
</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
<link rel="stylesheet" href="css/bootstrap.min.css"/>
<?php

session_start();
if (isset($_POST['submit'])) {
    include "dbconnection.php";
    $puzzle_id = mysql_real_escape_string($_POST['puzzle_id']);
    $rhymes = getPuzzleById($puzzle_id);
    $rhyme = mysql_fetch_array($rhymes);
    $rhyme_seo = $rhyme['seo_puzzle'];
    if (isset($_SESSION['user_id'])) {
        $users = getUserById($_SESSION['user_id']);
        $user = mysql_fetch_array($users);
        $comments = mysql_real_escape_string($_POST['comments']);
        addPuzzleComments($puzzle_id, $comments, $_SESSION['user_id']);
        $base_url = "http://thefunkids.com/admin";
        $subject = "Comments on Rhymes for Moderation";
        $from = "*****@*****.**";
        $to = "*****@*****.**";
        $mail_body = "Dear All,<br/><br/> A comment has been posted on our website TheFunKids.com and is pending approval. Kindly review and <br /><br /> moderate whether the comment should be posted or not.<br /><br /><br/>Login Url:<a href=" . $base_url . ">" . $base_url . "</a><br/><br/><strong>User Name:</strong>admin@thefunkids.com<br><strong>Password:</strong>admin123<br/></br>Regards & Love<br/><br/>The Fun Kids Team";
        $body = wordwrap($mail_body, 2000);
        //$body_user = wordwrap($mail_body_user,70);
        $headers = "MIME-Version: 1.0" . "\r\n";
        $headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
        $headers .= "From: " . $from . "\r\n";
        $headers .= 'Bcc:amohsin@golive.com.pk,saher@golive.com.pk' . "\r\n";
        //------------------------Thanks You Email-------------------------------------------------------------------
        mail($to, $subject, $mail_body, $headers);
        header("location:kid-puzzle-{$rhyme_seo}&comment#puzzles");
    } elseif (isset($_SESSION['FBID'])) {
        $user_facebook_id = getUserByFaceBookId($_SESSION['FBID']);
        if ($user_facebook_id) {
            <div class="col-md-8">
              <!-- MAP & BOX PANE -->
              <!-- /.box -->
              <!-- /.row -->

              <!-- TABLE: LATEST ORDERS -->
              <div class="box box-info">
                <!-- /.box-header -->
                <div class="box-body">
                  <div class="table-responsive">
                   
                <!-- /.box-header -->
                <!-- form start -->
                <?php 
$puzzle_id = mysql_real_escape_string($_REQUEST['id']);
$result = getPuzzleById($puzzle_id);
$puzzle = mysql_fetch_array($result);
?>
                <form role="form" method="post" action="doupdatepuzzle.php" enctype="multipart/form-data">
                    <input type="hidden" name="puzzle_id" value="<?php 
echo $puzzle['puzzle_id'];
?>
">
                    <div class="form-group">
                      <label for="exampleInputEmail1">Puzzle Name</label>
                      <input type="text" name="puzzle_name" class="form-control" id="puzzle_name" value="<?php 
if (isset($puzzle['puzzle_name'])) {
    echo $puzzle['puzzle_name'];
}
?>
" >