I have this form that looks like so in a cgi file:
print "<FORM NAME='LAYOUTFORM' ACTION='Handler.cgi' METHOD=POST>";
print "<table border='0' align=center>\n";
print "<tr><td>Search by:<SELECT ID='Forms Combo Box1' NAME='what_to_do'><OPTION VALUE='title'>Title</OPTION><OPTION VALUE='description'>Description</OPTION><OPTION VALUE='author'>Author</OPTION></td>";
print "<td><INPUT ID='SearchArea' TYPE=TEXT NAME='searchbox' VALUE='' SIZE=27 MAXLENGTH=100></td>";
print "<td><INPUT TYPE=SUBMIT NAME='searchbutton' VALUE='Search' ID='Form_Search'></td></tr>";
print "</table>\n";
print "</form>";
Then I have this:
#!/usr/local/bin/perl
use DBI;
use DBD::mysql;
use CGI qw(:standard);
$searchinput = param('searchbox');
print "Content-type: text/html\n\n";
my $dbh = DBI->connect( "DBI:mysql:database", "username", "password" ) or
die( "Could not make connection to database: $DBI::errstr" );
my $sth = $dbh->prepare( q(SELECT * FROM BookStore WHERE bAuthor = $searchinput) ) or
die( "Cannot prepare statement: ", $dbh->errstr(), "\n" );
my $rc = $sth->execute() or
die( "Cannot execute statement: ", $sth->errstr(), "\n" );
I am getting this error in commandline:
Uknown column '$searchinput' in 'where clause' at Search.cgi line 17.
What I am trying to do is the user would enter a name into the textbox on the main.cgi. Then hit the search button and the search.cgi would retrieve the info of the row that matches in the column of the table.