PHP error: Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

0

Hello my problem is that I am trying to make an insert in mysql, taking the data of the following form:

I know it's a problem that I'm putting the wrong route or permission, but I can not find where I screwed up. For this I use the file "addPedido.php" that I attached below

The php file is in the same folder as the file on the form.

<body>
<h1>Formulario de Compra</h1>
<div class="f">
    <form method="get" action="añadirPedido.php">

        <div class="form-group">
            <label for="dni">Introduzca su dni</label>
            <input type="text" class="form-control" id="dni" placeholder="DNI">

        </div>
        <div class="form-group">
            <label for="nombre">Introduzca su nombre</label>
            <input type="text" class="form-control" id="nombre" placeholder="nombre">

        </div>
        <div class="form-group">
            <label for="apellidos">Introduzca sus apellidos</label>
            <input type="text" class="form-control" id="apellidos" placeholder="apellidos">

        </div>
        <div class="form-group">
            <label for="direccion">Introduzca su dirección</label>
            <input type="text" class="form-control" id="direccion" placeholder="direccion">

        </div>
        <div class="form-group">
            <label for="tfno">Introduzca su teléfono</label>
            <input type="text" class="form-control" id="tfno" placeholder="tfno">

        </div>
        <div class="form-group form-check">
            <input type="checkbox" class="form-check-input" id="comfort">
            <label class="form-check-label" for="comfort">¿Desea la versión confort?(Esto aumentara un 20% el importe de la casa)</label>
        </div>
        <button type="submit" class="btn btn-primary">Submit</button>

    </form>
</div>

    <?php

    $link = mysqli_connect("localhost", "root","rootroot","paginacasas");
    if($link){
            $dni = $_POST['dni'];
            $nombre = $_POST['nombre'];
            $apellidos = $_POST['apellidos'];
            $direccion = $_POST['direccion'];
            $tfno = $_POST['tfno'];
            $comfort = $_POST['comfort'];
                if($comfort){
                    $bool=s;
                }else{
                    $bool=n;
                }
        $sql = "INSERT INTO Pedidos (dni, nombre,apellidos, direccion,tfno,comfort) VALUES ("."'".$dni."'".", "."'".$nombre."'".", "."'".$apellidos."'".", "."'".$direccion."'".", "."'".$tfno."'".", "."'".$comfort."'".")";

        $resultado=mysqli_query($link,$sql);
        if ($resultado) {
            echo "Pedido insertado correctamente";
        } else {
            echo "Error: " . $sql . "<br>" . $mysqli->error;
        }


        $link->close();

        }

?>
    
asked by Javir Gallegos García 16.12.2018 в 20:59
source

1 answer

-1

I think the answer is simple, if not I'm wrong. You are sending the form by GET and you are looking for if something arrived for POST, try that and comment.

Another thing, I always advise you to use the POST method, since with get, the data you enter, are reflected in the url, and always use prepared queries, you will avoid injections.

I leave you a piece of code how I collect the data in php of a form.

if (isset($_POST['usuario'])){
    $usuario=strip_tags(trim($_POST['usuario']));
}
    
answered by 16.12.2018 / 22:28
source