Error in data editing page

Asked

Viewed 28 times

-2

good night! I have a page for editing the user data that is logged in at that time in the account, however, I am receiving an error message from the page:

inserir a descrição da imagem aqui

Here is the php code of the page:

<?php
    include("../banco/conexao.php");

    if(isset($_GET['id'])) {
        $id = $_GET['id'];
        $query = "SELECT * FROM usuario WHERE id=$id";
        $result = mysqli_query($conexao,$query);
    if(mysqli_num_rows($result) == 1) {
        $row = mysqli_fetch_array($result);
        $nomeUsuario = $row['nomeUsuario'];
        $cpfUsuario = $row['cpfUsuario'];
        $usuario = $row['usuario'];
        $emailUsuario = $row['emailUsuario'];
        $senhaUsuario = $row['senhaUsuario'];


    }
    if(isset($_POST['salvar'])) { 
        $id = $_GET['id'];
        $nomeUsuario = $_POST['nomeUsuario'];
        $cpfUsuario = $_POST['cpfUsuario'];
        $usuario = $_POST['usuario'];
        $emailUsuario = $_POST['emailUsuario'];
        $senhaUsuario = $_POST['senhaUsuario'];

        $query = "UPDATE usuario SET nomeUsuario = '$nomeUsuario', cpfUsuario = '$cpfUsuario', usuario = '$usuario',
        emailUsuario = '$emailUsuario', senhaUsuario = '$senhaUsuario' WHERE id = $id";
        mysqli_query($conexao,$query);

        echo "<script type='text/javascript'>window.alert('Usuário Editado com Sucesso!');</script>";
        echo '<meta HTTP-EQUIV="Refresh" CONTENT="1; URL=pagUsuario.php">';
        exit;

        header("Location: pagUsuario.php");
    }

    }

?>

And line 61, where he’s saying it contains the error:

<form action="editarPerfilUsuario.php?id=<?php echo $_GET['id']; ?>" method="">

I’m having a hard time because it’s a college project and I’m doing it together with other colleagues, but even they’re having trouble understanding it themselves, someone could give a help?

1 answer

0

its error is the lack of the method, the page expects to receive the data via POST, except for the id that would go via GET.

<form action="editarPerfilUsuario.php?id=<?php echo $_GET['id']; ?>" method="POST">

read about forms in HTML:

https://www.w3schools.com/html/html_forms.asp

Browser other questions tagged

You are not signed in. Login or sign up in order to post.