#!"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(
'
Welcome To CloseWalk a Christian article/sermon website that help you build your faith and relationship with the almight God.
' .$message. '
'); &author_profile($author_id); print( 'So while it’s not inappropriate to explore the path of spiritual growth, 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.
Read More