MySQL Forums
Forum List  »  Perl

Parsing URL/Form to grab ID for MySQL
Posted by: Mason Black
Date: March 12, 2011 05:34PM

I have a webpage that randomly brings up two fields from a MySql DB.

A 'user' will click on a button to decide which of the two fields they would like to select:

<button id = "1" onClick="loadXMLDoc('$rndnum1')">Choose $name1</button>
<button id = "2" onClick="loadXMLDoc('$rndnum2')">Choose $name2</button>

Javascript will then 'POST' the 'Form' so the proper $id gets attached to the URL:

function loadXMLDoc(url)
var xmlhttp;"POST",url,true);

Here's the thing.... I don't want to leave the original page, I only want to have it reload when the button is clicked.
But, at the same time, I'd like to use another Perl page to parse the URL that was passed and change fields in a DB based on the parameters (id) that was passed in the URL.

Everything works fine, except when I parse the URL the parameters are showing up as Null???
The page gets called fine, so what am I doing wrong to 'grab' the ID from the URL??

Here is the '' page's code:
use CGI;
my $cgi = CGI->new();
my $myid = $cgi->param("id");
print $myid; #this line isn't printing anything at all

Once I have the '$myid' everything else should be fine.

Thanks in advance for your help!!!!

Options: ReplyQuote

Written By
Parsing URL/Form to grab ID for MySQL
March 12, 2011 05:34PM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.