Problem with css styles when passing variables by GET in PHP

0

I am sending a variable through the GET method in PHP, it receives it and executes the actions correctly, the problem is with the CSS styles, the procedure is as follows:

1- Send $ id through the GET method from AppTarea / index.php

<div class="opciones">

    <a href="Modelo/editar.php/?id=<?php echo $datos['id']; ?>">
        <i class="fa fa-pencil-square-o editar"></i>
    </a>

</div>

2- Model / edit.php receives the varible, before receiving the variable $ id the page looks like this - > edit.php, and receive CSS styles

but then it no longer receives them because the url changes upon receiving the variable - > edit.php? id = 1

I do not know what's happening, someone can help.

AppTarea's full code / index.php, the data comes from the database.

<?php 
include_once('Modelo/Tareas.php');
 ?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>App Terea</title>
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/estilos.css">
</head>
<body>
    <div id="App">
        <h1 class="nombre">TARE-APP</h1>
        <h2>Tareas Creadas</h2>
        <?php 
            $tarea = new Tareas();
            $resul = $tarea -> selectTarea();
            foreach ($resul as $datos) { ?> 

                <div class="tarea" id="1">
                    <div class="fecha_hora">
                        <h3><?php echo $datos['hora']; ?> </h3>
                        <h3><?php echo $datos['fecha']; ?></h3>
                    </div>
                    <section class="info">
                        <h1><?php echo $datos['titulo']; ?></h1>
                        <p><?php echo $datos['descripcion']; ?></p>
                    </section>
                    <div class="opciones">
                        <a href="Modelo/editar.php/?id=<?php echo $datos['id']; ?>""><i class="fa fa-pencil-square-o editar" aria-hidden="true"></i></a>
                        <a href="Modelo/eliminar.php/?id_tarea=<?php echo $datos['id']; ?>"><i class="fa fa-trash eliminar" aria-hidden="true"></i></a>

                    </div>
                </div>
            <?php } ?>

        <a href="Crear-Tarea"><div class="btnCrearTarea"> <span class="fa fa-plus"></span></div></a>
    </div>          
</body>
</html>

Model complete code / edit.php

<?php 
include_once('../Modelo/Tareas.php');
$id = $_REQUEST['id'];
$tarea_vieja = New Tareas();
$result = $tarea_vieja -> selectTarea($id);

 ?>
<!DOCTYPE html>
<html lang="Es">
<head>
    <meta charset="UTF-8">
    <title>Crear Nueva Tarea</title>
    <link rel="stylesheet" href="../css/font-awesome.min.css">
    <link rel="stylesheet" href="../css/estilos.css">
</head>
<body>
<div id="App">
    <h1 class="nombre">TARE-APP</h1>
    <a href="../index.php"><i class="fa fa-arrow-circle-left flecha_volver" aria-hidden="true"></i></a>
    <h2>Crear nueva tarea</h2>
    <?php foreach ($result as $datos) { ?> 
        <form action="" method="post">
            <input type="text" value="<?php echo $datos['titulo']; ?>" name="titulo" required placeholder="Titulo Tarea" class="titulo" ><br>
            <textarea name="descripcion" maxlength="100" cols="22" rows="5" autocomplete="on" placeholder="Descripcion" class="descripcion"> <?php echo $datos['descripcion']; ?> </textarea><br>
            <input type="text" value="100" class="caracteres"><br>
            <input type="time" value="<?php echo $datos['hora']; ?>" name="hora" required class="hora"><br>
            <input type="date" value="<?php echo $datos['fecha']; ?>" name="fecha" required class="fecha"><br>

            <input type="submit" value="Editar" name="editar" class="btn_crear">
        </form>
    <?php } ?>
</div>

<?php 

if(isset($_POST['editar']) and !empty($_POST['editar'])) {
    $titulo_nuevo = $_POST['titulo'];
    $desc_nuevo   = $_POST['descripcion'];
    $hora_nuevo   = $_POST['hora'];
    $fecha_nuevo  = $_POST['fecha'];

    // Pasar datos al objeto de la clase Tareas para actualizar
    $tarea = new Tareas($titulo_nuevo, $desc_nuevo, $hora_nuevo, $fecha_nuevo);
    $tarea -> updateTarea($id);
    echo "<div id='msm'> <p> Tarea actualizada </p> </div>";
}


</body>
</html>
    
asked by Odannys De La Cruz 23.11.2017 в 23:37
source

2 answers

0

I think the problem is in these lines of code

<link rel="stylesheet" href="css/font-awesome.min.css">
<link rel="stylesheet" href="css/estilos.css">

the browser is looking for styles in

www.loquesea.com/editar.php?id=1css/estilos.css 

try to change that by some fixed lines ex:

href="www.loquesea.com/css/estilos.css">
    
answered by 24.11.2017 в 23:07
0

What happens is that the new page with the id in the url, does not point to where the CSS is. What you can do is modularize your project, creating a new .php file for header (can be header.php ), you will include all calls to external and internal files that you need to load in your body, from styles, scripts, etc. .

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>App Terea</title>
    <link rel="stylesheet" href="css/font-awesome.min.css">
    <link rel="stylesheet" href="css/estilos.css">
</head>

Then you should only do a require_once on any page .php that you believe, with the path of your header just like you do with tareas.php . Next, you must open with the <body> tags and start working normally.

<?php 
  require_once('header.php');
  include_once('../Modelo/Tareas.php');
?>

<body>

<!-- Todo tu contenido -->

</body>

The good thing about doing this is that if you need to modify something in header you only have to do it once in a single file and it will be applied to the rest where you include it. This is also applicable for footer .

    
answered by 25.11.2017 в 01:50