Received: from newman.hartehanks.com (newman.hartehanks.com [204.89.158.3]) by mail.postgresql.org (8.11.1/8.11.1) with ESMTP id f0MEn0034226 for ; Mon, 22 Jan 2001 09:49:00 -0500 (EST) (envelope-from Timothy_Maguire@hartehanks.com) Received: from linmail.hartehanks.com (unverified) by newman.hartehanks.com (Content Technologies SMTPRS 4.1.5) with SMTP id ; Mon, 22 Jan 2001 09:40:30 -0500 Received: by linmail.hartehanks.com(Lotus SMTP MTA v4.6.6 (890.1 7-16-1999)) id 852569DC.00511C07 ; Mon, 22 Jan 2001 09:45:55 -0500 X-Lotus-FromDomain: HARTE-HANKS From: Timothy_Maguire@hartehanks.com To: s cc: pgsql-php@postgresql.org Message-ID: <852569DC.0051195F.00@linmail.hartehanks.com> Date: Mon, 22 Jan 2001 09:45:40 -0500 Subject: Re: query checking Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Content-Disposition: inline X-Archive-Number: 200101/65 X-Sequence-Number: 130 You can try using the ereg() or eregi() functions and check for what the user inputed. For example: if (eregi("delete", $query) { echo " you can not delete from table"; } elseif ( (eregi("select", $query) || (eregi("update", $query) || (eregi("insert", $query) ) { execute $query;..... } Hope this helps. Tim. s on 01/21/2001 07:44:20 PM To: pgsql-php@postgresql.org cc: (bcc: Timothy Maguire/Data-Technologies/Harte-Hanks) Subject: query checking I am writing a site that does select/insert SQL commands with users input. There is a potential hazard if some one tries to execute there own commands in an input box eg. the user types into the input box on a form - [ "; delete * from table; ] I'm after a regular expression (that'd be nice) or an algorithm to tell that only one query is being passed to psql at a time. The query string will be processed if Either - one SELECT command only - one INSERT command only - one UPDATE command only ELSE - dont process query Any input would be much appreciated. thanks, stef