#!"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,$password) || 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 where 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 data from the database: $dbh->errstr()"); my($article_id,$date_added,$article_title,$author_id,$image,$message) = @data; $message =~s/\n/
/; print( ' '.$article_title . '

Todays Bible Qoute:

For sin shall not have dominion over you; for ye are not under the law but under grace

Welcome To CloseWalk a Christian article/sermon website that help you build your faith and relationship with the almight God.

Latest Articles

'.$article_title.'


Published: '.$date_added . '

' .$message. '

'); &author_profile($author_id); print( '
'); } sub author_profile { my $author_id = shift(@_); my $statement = qq{select title,f_name,l_name,profile,image from author 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 statement: $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('

About this author

'.ucfirst($title).' '.ucfirst($f_name) .' '. ucfirst($l_name) .'

'.$profile. '

'); }