MySQL Forums
Forum List  »  Perl

where to place the statements?
Posted by: Naveen Gupta
Date: May 02, 2005 04:38AM

hi nick,
earlier i made a script view_profile.pl which was to show the profile if the button was clicked. but how can i pass the $chkuser parameter to this new script from the main script, based upon which it will create the sql statement to select a profile to show from the db??

Another thing i tried as u said in the above post --- i placed the two buttons and the code to implement them in nested if statements in the main script within the code to check the pwd. So it looked like --

if ($md5password eq $pass)
{
print "<p> You have successfully logged in $chkuser!<p>";
print "<html>;
print "<form method='POST'>";
print "<input type='submit' name='submit' value='View Profile'> <input type='submit' name='submit' value='Update Profile'>";
print "</form>";
print "</html>";
@params = $query->param();
$action=$query->param("submit");

if ($action eq "View Profile")
{
$dbh = DBI->connect("DBI:mysql:database=$db:host=$host", $user, $password) or die "Can't connect to database:$DBI::errstr\n";
$qry = $dbh->prepare("SELECT emp_id, emp_name, permanent_address, dob, permanent_phone FROM new_user where emp_name='$chkuser'");
$qry->execute;

@vrow=$qry->fetchrow_array;

print "Content-type: text/html\n\n";

print "<hr>";
print "<p>Employee ID is : @vrow[0]</p><br>";
print "<p>Employee Name is : @vrow[1]</p><br>";
print "<p>Employee Address is : @vrow[2]</p><br>";
print "<p>Employee's Date of Birth is : @vrow[3]</p><br>";
print "<p>Employee's Phone No. is : @vrow[4]</p><br>";
print "<hr>";

$dbh->disconnect;
print $query->end_html();


}

elsif ($action eq "Update Profile")
{
print "<p>Update</p>";
}
else
{
print "<p> Click a Button!</p>";
}

$dbh->disconnect;
print $query->end_html();
}
But in this case i'm getting lot of errors on command line and in the browser, the progress bar is getting stuck midway, not producing any output.
Wt to do? which way to go and wt code to write
With regards
naveen

Options: ReplyQuote


Subject
Written By
Posted
May 02, 2005 01:16AM
May 02, 2005 02:19AM
May 02, 2005 04:08AM
where to place the statements?
May 02, 2005 04:38AM
May 02, 2005 06:08AM
May 02, 2005 06:19AM
May 02, 2005 06:36AM
May 02, 2005 07:25AM
May 02, 2005 11:49PM
May 03, 2005 03:58PM
May 04, 2005 04:55AM


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.