Note that there are some explanatory texts on larger screens.

plurals
  1. POperl multiple forms problem
    primarykey
    data
    text
    <p>Hy guys! My first time developing an Perl web application. I have a page with 2 forms , on submit each going on separate other pages. The problem is as follows: When submiting the second form it goes on the first form action. Params are send through Get method and the url contains the input string from both forms. Here is the code.</p> <pre><code>#!C:\Perl\bin\perl use DBI; use DBD::mysql; print "content-type: text/html \n\n"; print '&lt;html&gt;'; print '&lt;body&gt;'; # DBI CONFIG VARIABLES $host = "localhost"; $database = "t2"; $port = 3308; $user = ""; $pw = ""; #DATA SOURCE NAME $dsn = "dbi:mysql:$database:localhost:3306"; # PERL DBI CONNECT (RENAMED HANDLE) $conn = DBI-&gt;connect($dsn, $user, $pw) or die "Unable to connect: $DBI::errstr\n"; $query = 'SELECT * From book'; $query_handle = $conn-&gt;prepare($query); # EXECUTE THE QUERY $query_handle-&gt;execute(); $query_handle-&gt;bind_columns(\$id, \$title ,\$author ,\$price, \$stock); print '&lt;table border="1"&gt;'; print '&lt;thead&gt;'; print '&lt;tr&gt;'; print '&lt;td&gt; Id &lt;/td&gt;'; print '&lt;td&gt; title&lt;/td&gt;'; print '&lt;td&gt; Author &lt;/td&gt;'; print '&lt;td&gt; price&lt;/td&gt;'; print '&lt;td&gt; Stock &lt;/td&gt;'; print '&lt;td&gt; Buy &lt;/td&gt;'; print '&lt;/tr&gt;'; print '&lt;/thead&gt;'; while($query_handle-&gt;fetch()) { print '&lt;tr&gt;'; print '&lt;td&gt;'; print $id; print '&lt;td\&gt;'; print '&lt;td&gt;'; print $title; print '&lt;td\&gt;'; print '&lt;td&gt;'; print $author; print '&lt;td\&gt;'; print '&lt;td&gt;'; print $price; print '&lt;td\&gt;'; print '&lt;td&gt;'; print $stock; print '&lt;td\&gt;'; print '&lt;td&gt;'; if ($stock ne '0') { print '&lt;form name="form1" action = "http://localhost/t3/buyBook.pl" method="get"&gt;'; print '&lt;input type="hidden" name="buy_id" value="'.$id.'"'; print '&lt;input type="submit" name="buy" value="Buy"'; print '&lt;form\&gt;' }else { print '&lt;input type="submit" name="buy" disabled="disabled" value="Buy"'; } print '&lt;td\&gt;'; print '&lt;tr\&gt;'; } print '&lt;/table&gt;'; print '&lt;form name="form2" action="http://localhost/t3/search_book.pl" method="get "&gt;'; print '&lt;br/&gt;'; print 'Search for book by:'; print '&lt;br/&gt;'; print '&lt;input type="radio" name="searchBy" value="Title"&gt; Title &lt;br/&gt;'; print '&lt;input type="radio" name="searchBy" value="Author"&gt; Author &lt;br/&gt;'; print '&lt;input type="text" name="search_book" &gt;'; print '&lt;br/&gt;'; print '&lt;input type="submit" name="search" value="Search"&gt;'; print '&lt;/form&gt;'; print '&lt;body/&gt;'; print '&lt;html/&gt;'; </code></pre> <p>Here is the url shown when pressing any of the 2 submit buttons: <a href="http://localhost/tema3/buyBook.pl?buy_id=7505&amp;buy_id=2&amp;buy_id=12195&amp;search_book=&amp;search=Search" rel="nofollow">http://localhost/tema3/buyBook.pl?buy_id=7505&amp;buy_id=2&amp;buy_id=12195&amp;search_book=&amp;search=Search</a></p> <p>Any idea how to fix this? Andrew</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload