User Login in HTML - SQL Query - Dump Data back to HTML Page.

Say I have a web page made from a Template, and the editable area is made up of a HTML table.

I want to make up a perl script that will ask for a user name/password login, then after you submit the info, the perl script connects to a Mysql database on the localhost using the POST data. It then performs a basic query (SELECT * FROM TABLE), and then dumps the query back into the orgional HTML table on the HTML template or dumps the info to a new page but made from the same template and dumping into the correct HTML Table.

Note that the login page should be contained inside the HTML template Table.

The main thing would be that instead of getting a new clear page made from the cgi script, I would get the actual query back into the template I started with.  It wouldn't matter if the page was reloaded, as long as the rest of the template was still there.

Did I explain this correctly? Is this possible?

Thanks a bunch.
Who is Participating?
MacaneConnect With a Mentor Commented:
i'm using ReadParse this basicly takes any values in a form send by POST or GET and puts it into an array, which then will contain your previously posted data.

// code snippet start //
#Let's say you got a form with 2 fields firstname and lastname
require "";

#First run of page
if (!&data) {
#if nothing was in the data var this must be the first time the page is run print the form.
  Do you thing here with form html code.
else {
#it seems that something was in the form.
  Do your thing with Html just add theese into the data place of the form.
// code snipper stop //

To get the data out of the data array do like this.
I would suggest that you build it up with some if sentences like this.
$lastname = "";
if ($data{'lastname'} {
  $lastname = $data{'lastname'}
and then simply make a sub that prints the form html with the $variables in them.

Hope this helps a bit if not just ask :)

> .. as long as the rest of the template was still there.

what do you mean by "there" ?
Could you please explain.
AirgazmAuthor Commented:
Well, I am new to CGI and perl and I have written a few web pages.  

All the simple scripts I have got working present the data in a new page.  I mean if I ask for variables in a HTML form and submit it, the data returned goes into a new page.

I want to get that data back into the page I started from or at least make it look like it is in the same page.  

I can get it to work with PHP, because PHP lets you mesh the PHP code in with the HTML, but that dosen't seem to be the case with Perl.  I just found out about Mason, is that what I should be using here to do this?

I forgot about the html part, but it should be a simple task to create a search sentence when you got the transfer of variables from page to page going.

for instance.

$searchstring = "SELECT * FROM TABLE WHERE LASTNAME=$lastname"

Or whatever you need todo with the variables.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.