checking for data before doing sql insert

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bart Nessux

    #1

    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

  • kingofkolt

    #2
    Re: checking for data before doing sql insert

    one idea is to do something like this...

    function checkForm() {
    if (!empty($_REQUE ST['formitem1']) && !empty($_REQUES T['formitem2'] &&
    !empty($_REQUES T['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@ho tmail.com> wrote in message
    news:c3n316$k8i $1@solaris.cc.v t.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]


    Comment

    Working...