|  | Posted by Rik on 07/20/07 23:46 
On Sat, 21 Jul 2007 01:37:24 +0200, nelson.salvador@gmail.com  <nelson.salvador@gmail.com> wrote:
 
 >
 > I have my code working now!
 >
 >
 > Unique field: ncheque
 > If emply will be NULL value
 >
 >
 > PHP:
 >
 >
 > if($_POST["titular"]!="" && $_POST["valorcheque"]!="" &&
 > $_POST["banco"]!="" && $_POST["datavencimento"]!=""){
 >                 $tipo_pagamento = $_POST["tipo_pagamento"];
 >                 $ncheque = $_POST["ncheque"];
 >             $ncheque = ($ncheque != "") ? "'" . $ncheque . "'" :
 > "NULL";
 >                 $titular = $_POST["titular"];
 >                 $valorcheque = virgulatoponto($_POST["valorcheque"]);
 >                 $banco = $_POST["banco"];
 >                 $vencimento = datatobanco($_POST["datavencimento"]);
 >                 $cidadeorigem = $_POST["cidadeorigem"];
 >                 $notas = $_POST["notas"];
 >                 $recibo = $_POST["recibo"];
 >                 $compra = $_POST["compra"];
 >                 $data = date("Y-m-d");
 >                 $db = new Database();
 >                 $db->query("Insert into pagamentos
 > (tipo_pagamento,titular,ncheque,vencimento,valor,datacadastro,banco,cidadeo
 > 
 > rigem,notas,recibo,compra)
 > values ('$tipo_pagamento','$titular',
 > $ncheque,'$vencimento','$valorcheque','$data','$banco','$cidadeorigem','$no
 > 
 > tas','$recibo','$compra')");
 >         }
 
 OK, and now is the time to learn about SQL-injection, and that you really
 should escape your strings. People could destroy your database with the
 form now.
 --
 Rik Wasmus
  Navigation: [Reply to this message] |