Here is the code i am working on i hope this helps explain what i am trying to achieve.
#!"c:/xampp/perl/bin/perl.exe"
use strict;
use warnings;
use diagnostics;
use CGI::Carp qw{fatalsToBrowser};
use CGI;
use DBI;
my $query = new CGI;
print($query->header());
my $article_id = undef;
#check if the article_id parameter has been set if not die immediately
if($query->param('article_id') eq "")
{
die("No parameter submited via the get method so this script most
+die here");
}else
{
$article_id = clean($query->param('article_id'));
&db_connect();
&process_article();
}
#Create a subroutine that cleans the data submited via the get method
sub clean
{
my $get = shift(@_);
$get =~ s/['\.\/-]*//g;
if(!int($get))
{
die('Invalid parameter submited Script most die here');
}
return($get);
}
my $dbh;
#A subroutine for the database connection
sub db_connect
{
my($database,$db_server,$user,$password) = ('closewalk','localhost
+','root','' );
$dbh = DBI->connect("DBI:mysql:$database:$db_server",$user,$passwo
+rd) || die("$!");
}
#A subroutine that processes and displays the article
sub process_article
{
my $statement = qq{select article_id,DATE_FORMAT(date_added,'%D %M
+ %Y') as date,article_title,author_id,image,message from article wher
+e article_id = '$article_id'};
my $sth = $dbh->prepare($statement) || die("Cannot prepare the sql
+ statement for execution : $dbh->errstr()");
my $rv = $sth->execute() || die("Cannot execute the statement for
+process_article : $dbh->errstr()");
my @data;
(@data = $sth->fetchrow_array()) || die("Cannot fetch the row of d
+ata from the database: $dbh->errstr()");
my($article_id,$date_added,$article_title,$author_id,$image,$messa
+ge) = @data;
$message =~s/\n/<br \/>/;
print(
'
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="/business/religious_semon
+s.css" media="screen" />
<title>'.$article_title . '</title>
</head>
<body>
<div id="wrapper">
<div id="text">
<h3>Todays Bible Qoute:</h3>
<marquee behavior="alternate">For sin shall not have dominion over you
+; for ye are not under the law but under grace</marquee>
</div>
<div id="box_top">
<div id="logo">
<h1><a href="#">CloseWalk</a></h1>
</div>
<div id="slogan">
<h3><q>Welcome To CloseWalk a Christian article/sermon website that he
+lp you build your faith and relationship with the almight God.</q></h
+3>
</div>
</div><!--close of box_top division-->
<div id="navigation">
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">Articles</a></li>
<li><a href="#">Sermons</a></li>
<li><a href="#">Testimony</a></li>
<li><a href="#">Online Store</a></li>
</ul>
</div>
<div id="latest">
<h1>Latest Articles</h1>
<div id="holder">
<figure>
<img src="../html/images/6-1-Where-is-Your-Hope.jpg" width="210" heigh
+t="150" />
</figure>
<h2><a href="#">This is the lords doing and it is marvelouse in our si
+te</a></h2>
</div>
<div id="holder">
<figure>
<img src="../html/images/6-13-Believe-in-the-Holy-Spirit.jpg" width="2
+10" height="150" />
</figure>
<h2><a href="#">God\'s own University which all men most pass throughs
+</a></h2>
</div>
<div id="holder">
<figure>
<img src="../html/images/imagesforchurch/worship2.jpg" width="210" hei
+ght="150" />
</figure>
<h2><a href="#">God has what it takes to set the captive free</a></h2>
</div>
<div id="holder">
<figure>
<img src="../html/images/imagesforchurch/Family-Worship-Background.jpg
+" width="210" height="150" />
</figure>
<h2><a href="#">I am my house hold shall serve the almighty God</a></h
+2>
</div>
</div><!--close of latest division of this site -->
<div id="body">
<div id="semon">
<h1>'.$article_title.'</h1>
<hr />
<span><strong>Published: </strong>'.$date_added . '</span>
<div id="image">
<figure>
<img src="/cgi-bin/image.pl?image='.$image .'" width="220" height="150
+" />
</figure>
</div>
<p>' .$message. '</p>
');
&author_profile($author_id);
print(
'
</div><!--close of sermon division -->
<div id="advert">
<div id="guest">
<h1>Guest Writer</h1>
<figure title="Todays Guest Writer">
<img src="../html/images/imagesforchurch/jesus-name-wallpaper-01.jpg"
+width="308" height="120" alt="Guest Writer" />
</figure>
<h2><a href="#" class="title">A woman has to be a cover for her family
+ at all times and she has to grow into a virtues woman</a></h2>
<p>So while it’s not inappropriate to explore the path of spiritual gr
+owth, we must avoid turning that path into a journey we can engineer
+on our own, and we must take care not to turn these stages into tools
+ to judge others or ourselves.
<br /><br />
<a href="#" class="link">Read More</a>
</p>
</div><!--close of guest division of this site -->
</div><!--close of advert division -->
</div><!--close of body division -->
<div id="footer">
<h1>©CloseWalk.com All Right Reserved 2014</h1>
<div id="links" align="center">
<a href="#">About Us</a>
<a href="#">Contact Us</a>
<a href="#">links</a>
<a href="#">partners</a>
<a href="#">Advertise with us</a>
</div>
</div>
</div><!--close of wrapper division -->
</body>
</html>
');
}
sub author_profile
{
my $author_id = shift(@_);
my $statement = qq{select title,f_name,l_name,profile,image from a
+uthor where author_id = '$author_id'};
my $sth = $dbh->prepare($statement) || die("Cannot prepare author
+statement for execution : $dbh->errstr()");
my $rv = $sth->execute() || die("Cannot execute author profile sta
+tement: $dbh->errstr()");
my @data;
(@data = $sth->fetchrow_array()) || die("Cannot fetchrow_array of
+author_profile");
my ($title,$f_name,$l_name,$profile,$image) = @data;
print('
<div id="author">
<h1>About this author</h1>
<figure>
<img src="/cgi-bin/author_photo.pl?image='.$image.'" width="180" heigh
+t="180" />
</figure>
<div id="profile">
<h5>'.ucfirst($title).' '.ucfirst($f_name) .' '. ucfirst($l_name) .'</
+h5>
<p>'.$profile. '</p>
</div>
</div>');
}