SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Dec 2013
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Database Not Updated

    I have this code, however it does not update the database...please need help...

    index.php
    HTML Code:
    <html>
    <form method="POST" action="listforn.php" name="funcionarios">
    
    Numero: <input type="text" name="palavra"/>
    
    <input type="text" name="mensagem">
    
    <input type="submit" value="Buscar"/>
    
    </form>
    
    </html>
    =====================================================
    listforn.php

    PHP Code:
    <HTML>
    <HEAD>
    <TITLE>Documento PHP</TITLE>
    </HEAD>
    <BODY>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Funcionarios</title>
    <link rel="stylesheet" type="text/css" href="estilos/main.css" />
    <script type="text/javascript">
    function delRecord(codpessoa) {
    var teste = confirm("Tem certeza que quer excluir o registro?");
    if (teste==false) {
    window.location = "listforn.php";
    }
    else window.location = "delforn.php?cod="+codpessoa;
    }
    </script>
    </head>
    <body>
    <table id="data">
    <caption>Listagem de Funcionários</caption>
    <tr>
    <th>ID</th>
    <th>Coligada</th>
    <th>Matrícula</th>
    <th>Chapa</th>
    <th>Seção</th>
    <th>Nome</th>
    <th>PIS</th>
    <th>Excluir</th>
    <th>Alterar</th>

    </tr>
    <?php
    # Conexão ao servidor MySQL
    # e seleção do banco Web21
    include("includes/conn.php");
    $palavra $POST'palavra';
    $sql="select from pfunc where id = ".$palavra."";
    $query mysqlquery($sql);
    while (
    $linha mysqlfetcharray($query)) {
    echo 
    "<tr>";
    echo 
    "<td>$linhaid</td>";
    echo 
    "<td>$linhacodcoligada</td>";
    echo 
    "<td>$linhacodpessoa</td>";
    echo 
    "<td>$linhachapa</td>";
    echo 
    "<td>$linhacodsecao</td>";
    echo 
    "<td>$linhanome</td>";
    echo 
    "<td>$linhapisparafgts</td>";
    echo 
    "<td style='text-align:center'>";
    echo 
    "<a href='javascript:delRecord(".$linha'id'.");'>X</a>";
    echo 
    "</td>";
    echo 
    "<td style='text-align:center'>";
    echo 
    "<a href='altforn.php?cod=".$linha'id'."'>";
    echo 
    "<img src='imagens/edit.png' border='0' width='16' height='16' /></a>";
    echo 
    "</td>";
    echo 
    "</tr>\n";
    }
    ?>
    </table>
    </body>
    </html>
    </table>
    </BODY>
    </HTML>
    ========================================================

    altforn.php

    PHP Code:
    <HTML>
    <HEAD>
    <TITLE>Documento PHP</TITLE>
    </HEAD>
    <BODY>
    <?php
    include("includes/conn.php");
    $sql="select from pfunc where id = '$GETcod'";
    $query mysqlquery($sql);
    $linha mysqlfetcharray($query);
    ?>
    <h1>Cadastro de Fornecedores</h1>
    <form id="form1" name="form1" method="post" action="doaltforn.php">
    <fieldset>
    <legend>Cadastro</legend>
    <label>ID:</label>
    <input type="text" name="id" readonly="readonly" value="<?php echo $linha'id';?>" /><br />
    <input type="text" name="codpessoa" readonly="readonly" value="<?php echo $linha'codpessoa';?>" /><br />
    <label for="nome">Nome:</label>
    <input type="text" name="nome" id="nome" value="<?php echo $linha'nome';?>" /><br />
    <label for="nome">Coligada:</label>
    <input type="text" name="codcoligada" id="codcoligada" value="<?php echo $linha'codcoligada';?>" /><br />
    <label for="nome">Chapa:</label>
    <input type="text" name="chapa" id="chapa" value="<?php echo $linha'chapa';?>" /><br />
    <label for="nome">Seção:</label>
    <input type="text" name="codsecao" id="codsecao" value="<?php echo $linha'codsecao';?>" /><br />
    <label for="nome">Pis:</label>
    <input type="text" name="pisparafgts" id="pisparafgts" value="<?php echo $linha'pisparafgts';?>" /><br />
    <label></label>
    <input name="enviar" type="submit" value="Alterar" />
    </fieldset>
    </form>
    </BODY>
    </HTML>
    ==========================================================
    doaltforn.php

    PHP Code:
    <?php
    include("includes/conn.php");
    $ideditar = (int)$GET'cod';
    $nome $POST'nome';
    $codcoligada $POST'codcoligada';
    $chapa $POST'chapa';
    $codsecao $POST'codsecao';
    $pisparafgts $POST'pisparafgts';

    $sql "UPDATE pfunc SET nome = '$nome', codcoligada = '$codcoligada', chapa = '$chapa', codsecao = '$codsecao', pisparafgts = '$pisparafgts'

    WHERE id = 
    $ideditar ";
    $query mysqlquery($sql) or die(mysqlerror());
    header("Location:index.php");
    Last edited by cpradio; Dec 3, 2013 at 13:26. Reason: Added php/html tags


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •