You are here: Re: Newbie question about UNIQUE MySQL v5.0.22 « All PHP « IT news, forums, messages
Re: Newbie question about UNIQUE MySQL v5.0.22

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация