in reply to Re^9: DBI, place holders and CGI forms
in thread DBI, place holders and CGI forms

I have a got a HTML form. It has multiple fields. The data should be inserted into the database using DBI. I'd like to use placeholders in the query. They aren't all required fields. I was wondering if I could use your method for dynamically inserting values into the database, or should I just insert everything after initialising in the general form $fieldname = $cgi->param('fieldname') || null;?

Replies are listed 'Best First'.
Re^11: DBI, place holders and CGI forms
by Corion (Patriarch) on Jun 20, 2011 at 08:51 UTC

    There is no null keyword in Perl.

    The value you're most likely thinking of is undef, and that's what $cgi->param(...) returns if no such field is found. So most likely, the below code already does what you might want:

    $fieldname = $cgi->param('fieldname')

    Note that the browser might send empty strings instead of missing values, depending on how your form is set up. But that's a different problem.

      sorry, I mixed up my perl and sql syntax.