UPDATE in PHP executes but does not update

2

Good evening !!! I am developing an application in college as requested by the teacher. Initially we were asked to make a CRUD. Of all the operations, the only one I could not do was the update. I have the impression that the registry ID is not being retrieved. can anybody help me? Here are codes:

Update.php

<?php
  //update.php
   include_once ("conectar.php");

    $name = $_POST["name"];
    $email = $_POST["email"];
    $id = $_POST["id"];

  
    $sql = "UPDATE pessoa SET PessoaNome='$name', PessoaEmail='$email'item.PessoaId = ".$id;
  
    if(mysqli_query($conexao,$sql)){
        $msg = "Atualizado com sucesso!";
    }else{
        $msg = "Erro ao atualizar!";
    }
    mysqli_close($conexao);    
      
    ?>

cadastro.html

<div class="page" data-name="cadastro">
  <div class="navbar">
    <div class="navbar-inner sliding">
      <div class="left">
        <a href="#" class="link back">
          <i class="icon icon-back"></i>
          <span class="ios-only">Voltar</span>
        </a>
      </div>
      <div class="title">Pessoa</div>
    </div>
  </div>
  <div class="page-content">
    <form class="list" action="cli.php" method="POST">
      <ul>
        <li>
          <div class="item-content item-input">
            <div class="item-inner">
              <div class="item-title item-label">ID</div>
              <div class="item-input-wrap">
                <input type="hidden" name="Pessoaid" id="idPessoa" placeholder="id">
              </div>
            </div>
          </div>
        </li>
        <li>
          <div class="item-content item-input">
            <div class="item-inner">
              <div class="item-title item-label">Nome</div>
              <div class="item-input-wrap">
                <input type="text" name="name" id="NomePessoa" placeholder="Your name">
              </div>
            </div>
          </div>
        </li>
        <li>
          <div class="item-content item-input">
            <div class="item-inner">
              <div class="item-title item-label">E-mail</div>
              <div class="item-input-wrap">
                <input type="email" name="email" id="EmailPessoa" placeholder="E-mail">
              </div>
            </div>
          </div>
        </li>
        <div class="item-content">
          <div class="item-inner">
            <div class="item-title">Toggle</div>
            <div class="item-after">
              <label class="toggle toggle-init">
                                    <input type="checkbox" name="toggle" value="yes"><i class="toggle-icon"></i>
                                </label>
            </div>
          </div>
        </div>
        </li>
      </ul>
    </form>
    <div class="block">
      <div class="row">
        <input class="col button button-fill" name="excluir" type="submit" id="excluir" value="Excluir!" />
        <input class="col button button-fill" name="salvar" type="submit" id="salvar" value="Salvar!" />
      </div>
    </div>
  </div>

ws.js

function atualizaPessoa(id){
	$.ajax({
		type: "POST",
		crossDomain: true,
		url: 'http://localhost/appaula/ws/update.php?id='+id,
		dataType: "text",
		async: false,
		success: function (result) {
			app.dialog.alert("Atualizado com sucesso");
		},
		error: function() {
			app.dialog.preloader('Erro ao atualizar pessoas');
		},
	});
}

Sorry, but I'm a good beginner, so forgive anything. Thanks in advance!

    
asked by anonymous 01.10.2018 / 02:07

1 answer

0

Hello, Locate the following line of your code:

$ sql="UPDATE person SET PersonName = '$ name', PersonEmail = '$ email'item.PessoaId=". $ id;

Replace with something like this: $ sql="UPDATE person SET PersonName = '$ name', PersonEmail = '$ email' WHERE PersonId = '$ id'";

This should make the update work, Abcs.

    
01.10.2018 / 04:33