Form html does not receive variable php from link

0

In the following code in between the values I try to enter the database does not store $ file_id why?

<!DOCTYPE html>
<html lang = "es">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Foro</title>
<link rel="stylesheet" href="css/style.css"/>
<link rel="shortcut icon" href="css/images/logo.png"/>
<script type="text/javascript" src="http://latex.codecogs.com/latexit.js"></script>
<script type="text/javascript">LatexIT.add('p',true);</script>
</head>

<?php 

include("conection.php");
session_start();

if(isset($_SESSION["user_name"]))
{

?>

<body>
<div id="agrupar" class="wrapper">

<header id="cabecera"><?php include("banner.php"); ?></header>

<nav id="menu"><?php include("panel.php"); ?></nav>

<section id="seccion">

<?php ob_start();

    $user = $_SESSION["user_name"];
    $file_id = $_GET["id_file"];
    if ($file_id == NULL){ header("Location: index.php");}
    $sql = "SELECT * FROM comment WHERE comment_file_id = '".$file_id."'";
    $data = mysqli_query($con, $sql) or die( mysqli_error($con));

    while($row = mysqli_fetch_array($data))
    {
        $comment = $row["comment"];
        $writtenby = $row["writtenby"];

ob_end_flush();?>

    <div class="comment">

<?php 

        echo "Usuario: <p>$writtenby</p></br>";
        echo "Comentario: <p style='font-weight: bold;'>$comment</p>"; 

?>
    </div>

<?php ob_start();

    }

ob_end_flush();?>

</section>

<aside id="columna">

    <div class="transparent-box">

        <div>Discusión sobre:</div>
        <div>Publicado por:</div>

    </div>

    <div id="posting">
        <form class="transparent-box" action="<?php ob_start(); echo $_SERVER['PHP_SELF']; ob_end_flush() ?>" method="post"  enctype="multipart/form-data">
            <textarea class="input-field" name="text" id="textarea" type="text" maxlenght = "140" rows="2" columns="70" placeholder=""/></textarea>
            <input type="submit" name="send" class="input-button" value="Comentar" />
        </form>
    </div>

<?php ob_start();    

        if(isset($_POST['send']))
        {
            if(empty($_POST['text']))
            { 
                echo "<script>alert('Comentario de texto vacío.')</script>";
            }//end if(empty
            else
            {
                $text = $_POST['text'];
                $sql = "INSERT INTO comment (writtenby, comment_file_id, comment) VALUES 
                    ('".$user."', '".$file_id."', '".$text."')";
                $reg = mysqli_query($con, $sql) or die(mysqli_error($con));
                if($reg) {header("Location: forum.php?id_file=".$file_id);}
                else {"<script>alert('Ha ocurrido un error.');</script>";}
            }
        }

ob_end_flush() ?>

</aside>

<footer id="pie"><?php include("footer.php"); ?></footer>

</div>
</body>

<?php

}

else{include("login.php");}

?>

</html>
    
asked by Alex Abarca 22.01.2017 в 02:23
source

0 answers