Re: Upload a file question



Thanks for the help Captain.

Ive had some problems recently with sql injection in ASP.

Im new in PHP. How can i protect the forms in PHP?

I will do a search in google in the meantime...

Once again, thanks

On 20 Jun, 11:22, Captain Paralytic <paul_laut...@xxxxxxxxx> wrote:
On Jun 20, 10:54 am, Pépê <josemariabar...@xxxxxxxxx> wrote:



Hi all.

Im a newbie in PHP and im trying to upload a file to the server.

I use a form to upload a pdf file and some text information about it.

The client uploads the file and the system renames that file and puts
all the information in the database.

The problem is when the client goes again to edit the information, i
always have to choose a file to upload or else it will put blank the
pdf column and he cant find the old one!

i do a $_POST['file'] to the UPDATE statement but i think i need to do
a if clause(and dont know what im going to put )...but where? i tried
it in the UPDATE statement and i cant..

Build your update statement dynamically. This is the sort of thing,
but you should sanitise the $_POST input.

if($_POST['file'])
  $fileup = ",file = '{$_POST['file']}'";
else
  $fileup = '';

$qry = "
INSERT INTO fred SET
  id = {$id},
  info1 = '{$info1}',
  info2 = '{$info2}
  {$fileup}
ON DUPLICATE KEY UPDATE
  info1 = '{$info1}',
  info2 = '{$info2}'
  {$fileup}
";

.



Relevant Pages

  • Re: [PHP] php5 and possible oop features/questions
    ... multiple files (as you must have one file with the class sometimes quite ... its just static, which may proove to be a bit of a problem, since the php ... OOP lacks dynamic patterns - in general it's a step back with what you could ... the existing OOP syntax takes a lot of work, and you cant please everyone. ...
    (php.general)
  • Could not open Paradox.net
    ... I have spent the past 2 days researching this and cant seem to get ... One machine has the paradox database on it (used by another program as ... Another computer has PHP and Apache on it. ...
    (php.general)
  • Could not open Paradox.net
    ... I have spent the past 2 days researching this and cant seem to get ... One machine has the paradox database on it (used by another program as ... Another computer has PHP and Apache on it. ...
    (comp.databases.paradox)
  • Could not open Paradox.net
    ... I have spent the past 2 days researching this and cant seem to get ... One machine has the paradox database on it (used by another program as ... Another computer has PHP and Apache on it. ...
    (microsoft.public.data.odbc)
  • UPDATE statement on an MDB
    ... the UPDATE statement with the OleDbCommand class wont work with me:( ... i cant seem to find the problem:( ...
    (microsoft.public.data.oledb)