update not work in perl programming
i already wrote the update program but its not work means its unable to update the data of table in database. my code just like that:
#!/usr/bin/perl -w
use CGI;
use DBI;
my $query= new CGI;
print $query->header();
print $query->start_html(-title=> 'Update Profile');
$toname=$ENV{QUERY_STRING};
$toname= ~ tr/+/ /;
$toname=~ s /%(..)/chr hex $1/eg;
if(($query->request_method eq "POST") && ($query->param("emp_name") ne '') && ($query->param("emp_add") ne '') && ($query->param("password") ne '') && ($query->param("city") ne '') && ($query->param("zip_code") ne '') && ($query->param("dob") ne '') && ($query->param("phone") ne '') && ($query->param("photo") ne ''))
{
$ename=$query->param("emp_name");
$eadd=$query->param("emp_add");
$pword=$query->param("password");
$ct=$query->param("city");
$zcode=$query->param("zip_code");
$d=$query->param("dob");
$ph=$query->param("phone");
$pto=$query->param("photo");
$dbh=DBI->connect("DBI:mysql:test:192.168.0.95","bobby","bobby") or die "Don't connect to Database:DBI::errstr\n";
$sth=$dbh->prepare("Update new_user SET emp_name='$ename',emp_add='$eadd',password='$pword',city='$ct',zip_code='$zcode',dob='$d',phone='$ph',photo='$pto' where emp_name=?");
$sth->execute($toname);
}
else
{
print"<HTML>";
print"<BODY>";
print"<FORM METHOD='POST' ACTION='test4.pl'>";
print"<p>         Employee Name:         ";
print"<input type='text' name='emp_name' value='$ename'></p><br>";
print"<p>        Employee Address:      ";
print"<input type= 'text' name='emp_add' value=$eadd></p><br>";
print"<p>        Password:                    ";
print"<input type ='password' name ='password' value='$pword'></p><br>";
print"<p>        City:                            ";
print"<input type = 'text' name='city' value='$ct'> </p><br>";
print"<p>        Zip Code:                    ";
print"<input type='text' name='zip_code' value='$zcode'></p><br>";
print"<p>         Date Of Birth:             ";
print"<input type=''text' name='dob' value='$d'></p><br>";
print"<p>         Phone:                        ";
print"<input type = 'text' name='phone' value='$ph'></p><br>";
print"<p>        Upload Photo:              ";
print"<input type='file' value='Browse'></p><br>";
print"<p><center><input type ='submit' value='update'></center></p>";
print"<center><a href='test2.pl'>Back to The Main Page</a></center>";
print"</FORM>";
print"</BODY>";
print"</HTML>";
print $query->end_html();
}
plz help me out from that problem.
good morning
arup ratan
Subject
Written By
Posted
update not work in perl programming
May 10, 2005 12:03AM
September 15, 2006 02:32AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.