Connecting Tech Pros Worldwide Help | Site Map

checking for data before doing sql insert

  #1  
Old July 17th, 2005, 05:20 AM
Bart Nessux
Guest
 
Posts: n/a
I have a html form (generated by PHP) that users can fill out and submit
into a database. Everything works fine. However, I'd like to check to make
sure that each field in the form actually contains data (no null/void
fields) before doing the insert into the database. Any tips on how to do
this?

Thanks,
Bart

  #2  
Old July 17th, 2005, 05:20 AM
kingofkolt
Guest
 
Posts: n/a

re: checking for data before doing sql insert


one idea is to do something like this...

function checkForm() {
if (!empty($_REQUEST['formitem1']) && !empty($_REQUEST['formitem2'] &&
!empty($_REQUEST['formitem3'] etc...) {
return true;
} else {
return false;
}
}

if (checkForm()) {
// insert stuff into database here because checkForm() returns true
} else {
print "Please fill out all fields in the form";
}


- JP

"Bart Nessux" <bart_nessux@hotmail.com> wrote in message
news:c3n316$k8i$1@solaris.cc.vt.edu...[color=blue]
> I have a html form (generated by PHP) that users can fill out and submit
> into a database. Everything works fine. However, I'd like to check to make
> sure that each field in the form actually contains data (no null/void
> fields) before doing the insert into the database. Any tips on how to do
> this?
>
> Thanks,
> Bart
>[/color]


Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command text was not set for the command object - error from dbms_lob.writeappend mbenedict answers 0 February 2nd, 2008 12:03 AM
Error checking for unique value in database table? Phil Latio answers 10 May 25th, 2007 05:35 AM
Checking for entry in database before insert Joey Lee answers 6 November 16th, 2005 09:38 PM
SQL Injection - Stored Procedures Bã§TãRÐ answers 11 July 22nd, 2005 02:45 AM