homepage Welcome to WebmasterWorld Guest from 54.204.73.126
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

    
Display results data from a perl cgi on a specific html page
Trying to get the results to show on a particular page
ashmax



 
Msg#: 4222028 posted 5:24 am on Oct 26, 2010 (gmt 0)

Hi

The setup:

I have a basic "Domain Search tool" on a "index.html" page that calls to a perl cgi script and then displays the found results on a "results.htmlt" page. The "results.htmlt" page code looks like this:

<h1>Results</h1>
[DATA]

All I would like to do is display these results "[DATA]" on the index.html page so that the domain search and the results stay on the same page.

If I change the cgi script and replace "results.htmlt" with "index.html" then put the [DATA] tag on the index.html page it does get the results and display them where I want them but im left with the [DATA] tag being visible before the search has been made.

How do I go about displaying the results on the same page without having to see the [DATA] tag first?

Hope this makes sense to somebody. Any help would be appreciated.
Thanks
Ash

 

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4222028 posted 5:39 am on Oct 26, 2010 (gmt 0)

welcome to WebmasterWorld [webmasterworld.com], Ash!

i am assuming you are searching for "[DATA]" in the template and replacing it with the search results?
try hiding the "[DATA]" and replacing the entire string.
something like:
<div style="visibility:hidden;">[DATA]</div>

ashmax



 
Msg#: 4222028 posted 6:20 am on Oct 26, 2010 (gmt 0)

Thank you for your reply:

<div style="visibility:hidden;">[DATA]</div>

I have tried what you suggested but this results with nothing being displayed unfortunately.

SteveWh

5+ Year Member



 
Msg#: 4222028 posted 9:27 am on Oct 26, 2010 (gmt 0)

When you search/replace the text, you must get rid of this attribute:
style="visibility:hidden;"

That's only for when there is no data to display.
After you have some data, you need to make it visible.

It's easy to get rid of
style="visibility:hidden;"
because you're replacing the whole tag with new text, including a new tag to contain the results.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4222028 posted 9:28 am on Oct 26, 2010 (gmt 0)

you have to replace the entire string including the div element tag, not just the "[DATA]".
or add some javascript in your replacement code that changes the visibility property, but that would make it javascript-dependent.

ashmax



 
Msg#: 4222028 posted 10:21 am on Oct 26, 2010 (gmt 0)

Thank you for your replies. But I have come up with a temp solution till I find out how to do it via javascript or php "include" etc....

I have created 2 identical pages with the same content but different extentions.

index.html
index.htmlt

The index.html page has the domain search on and the index.htmlt has both the domain search and the [DATA] tag on, when you search for a domain on the index.html, it calls to the index.htmlt [DATA] and displays the results on the index.htmlt page, this has the appearence that the index.html page is not changing when in fact it is.

phranque

WebmasterWorld Administrator phranque us a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



 
Msg#: 4222028 posted 10:37 am on Oct 26, 2010 (gmt 0)

you should make sure your serve is sending the correct content type header for the index.htmlt response:
Content-Type: text/html

also you want to consider if there will be any negative effects of having duplicate content if/when both urls are indexed.

chorny

5+ Year Member



 
Msg#: 4222028 posted 12:02 pm on Oct 28, 2010 (gmt 0)

You may use SSI include, but using Perl from HTML is not recommended. You need to submit form to a Perl program and read template from there.

SteveWh

5+ Year Member



 
Msg#: 4222028 posted 2:32 pm on Oct 28, 2010 (gmt 0)

using Perl from HTML is not recommended

I'm curious why that is.

Here is a method that works fine on my test server for a similar type of thing. I was going to suggest it to the OP, but it's rather involved, perhaps more than they wanted to deal with. Is there a reason not to do it this way?

The web page is an .html file that has PHP code in it, with the server properly configured to run the PHP code.

The page contains an HTML form that posts to the same page:
<form method="post" action="">

A block of PHP code in the page tests whether there was any form data submitted.

If there was no form data, the page is just rendered normally, without trying to process or put on the page form data that doesn't exist.

However, if there was form data submitted, PHP code sanitizes and validates it, then passes the submitted data to a Perl script:

$cmd = escapeshellcmd('perl -wT ' . escapeshellarg("path/to/my/script.pl") . 'various args');
$output = shell_exec($cmd);


$output contains whatever text the Perl script generated, which PHP then puts on the .html page at the needed location.

It seems to me the advantage is that it uses PHP for what it is good at: being embedded in the page to easily generate HTML code where it's needed, while Perl is used for the heavy text processing where speed is required, but not used for actually generating the HTML page, which (at least from my standpoint of Perl inexperience) is sort of cumbersome.

chorny

5+ Year Member



 
Msg#: 4222028 posted 4:17 am on Oct 30, 2010 (gmt 0)

It seems to me the advantage is that it uses PHP for what it is good at: being embedded in the page to easily generate HTML code where it's needed, while Perl is used for the heavy text processing where speed is required, but not used for actually generating the HTML page, which (at least from my standpoint of Perl inexperience) is sort of cumbersome.


Embedding code into HTML is considered bad style in any language, most PHP programmers do not know this, so it is used frequently. But even PHP has template systems.

I use Template Toolkit, other use other systems like HTML::Template. CGI::FastTemplate has even sevtral ports to PHP.

Also you can embed code into HTML in Perl too, but due to being not recommended, and requiring to install CPAN modules, it is not used frequently.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved