8.
Write a Perl program to insert name and age information entered by the user into a table created using MySQL and to display the current contents of this table.
8.html
<html>
<head>
<title>lab10</title>
</head>
<body bgcolor="#BBB777" text="black">
<h1> <center>Enter Student information </center></h1>
<center>
<form action="8.pl">
<br/> NAME<br/><input type="text" name="name"><br><br>
<br/>AGE <br/><input type="text" name="age"><br><br>
<input type="submit" value="Submit"></h2>
</form>
</center>
</body>
</html>
8.pl
#! /usr/bin/perl -w
use CGI ':standard';
use DBI;
print "content-type:text/html\n\n";
$name=param("name");
$age =param("age");
$dbh=DBI->connect("DBI:mysql:dbase1","root","");
$res1=$dbh->prepare("insert into pdetails values('$name','$age')");
$res1->execute();
$res=$dbh->prepare("select * from pdetails");
$res->execute();
print "<html><body bgcolor=#BBB777 text=black>";
print "<h2><center><br>THE CONTENTS OF THE DATABASE TABLE IS SHOWN BELOW <hr> <br>";
print "<table border=1>";
print "<tr><td>NAME</td><td>Age</td></tr>";
while(@a=$res->fetchrow_array())
{
print "<tr><td>$a[0]</td><td>$a[1]</td></tr>";
}
print "</table></center></h2></body></html>";
Write a Perl program to insert name and age information entered by the user into a table created using MySQL and to display the current contents of this table.
8.html
<html>
<head>
<title>lab10</title>
</head>
<body bgcolor="#BBB777" text="black">
<h1> <center>Enter Student information </center></h1>
<center>
<form action="8.pl">
<br/> NAME<br/><input type="text" name="name"><br><br>
<br/>AGE <br/><input type="text" name="age"><br><br>
<input type="submit" value="Submit"></h2>
</form>
</center>
</body>
</html>
8.pl
#! /usr/bin/perl -w
use CGI ':standard';
use DBI;
print "content-type:text/html\n\n";
$name=param("name");
$age =param("age");
$dbh=DBI->connect("DBI:mysql:dbase1","root","");
$res1=$dbh->prepare("insert into pdetails values('$name','$age')");
$res1->execute();
$res=$dbh->prepare("select * from pdetails");
$res->execute();
print "<html><body bgcolor=#BBB777 text=black>";
print "<h2><center><br>THE CONTENTS OF THE DATABASE TABLE IS SHOWN BELOW <hr> <br>";
print "<table border=1>";
print "<tr><td>NAME</td><td>Age</td></tr>";
while(@a=$res->fetchrow_array())
{
print "<tr><td>$a[0]</td><td>$a[1]</td></tr>";
}
print "</table></center></h2></body></html>";
No comments:
Post a Comment