Connecting Tech Pros Worldwide Help | Site Map

checking for data before doing sql insert

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 04:20 AM
Bart Nessux
Guest
 
Posts: n/a
Default checking for data before doing sql insert

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, 04:20 AM
kingofkolt
Guest
 
Posts: n/a
Default 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]


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.