#!usr/bin/perl use DBI; use CGI qw/:standard/; print header(); my $q = new CGI; my $oldpw = $q->param('txtPasswordOld'); my $newpw1 = $q->param('txtPasswordNew1'); my $newpw2 = $q->param('txtPasswordNew2'); my $name = $q->param('txtName'); my $user = ""; my $pwd = ""; my $server = "localhost"; my $db = "my_db"; my $dbh = DBI->connect("dbi:mysql:$db:$server",$user,$pwd); print ""; if ($newpw1 eq $newpw2){ my $query = "UPDATE User SET Password = Password($newpw1) where User='$name'"; my $sth = $dbh->prepare($query); $sth->execute(); print "Password changed."; } print ""; $dbh->disconnect;