Skip to content

Commit

Permalink
Added 10.
Browse files Browse the repository at this point in the history
  • Loading branch information
timothyandrew committed Nov 17, 2011
1 parent 14317c0 commit 2874490
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
28 changes: 28 additions & 0 deletions 10/10.cgi
@@ -0,0 +1,28 @@
#! /usr/bin/perl

use CGI ':standard';
use DBI;

print header();
print start_html('SQL');

$dbh = DBI->connect("dbi:mysql:student:localhost:3306","root","root");
print 'Connected';
$name=param("name");
$age=param("age");
$qh=$dbh->prepare("insert into user values('$name','$age')");
$qh->execute();
$qh=$dbh->prepare("Select * from user");
$qh->execute();

print "Table info: <br>";
print "<table border size=1><tr><th>Name</th><th>Age</th></tr>";

while ( ($name,$age)=$qh->fetchrow()){
print "<tr><td>$name</td><td>$age</td></tr>";
}

print "</table>";
$qh->finish();
$dbh->disconnect();
print"</HTML>";
8 changes: 8 additions & 0 deletions 10/10.html
@@ -0,0 +1,8 @@
<html>
<body>
<form action="/cgi-bin/10.cgi">
Name : <input type="text" name="name"> <br>
Age :<input type="text" name="age"> <br>
<input type="submit" value="Submit">
</form>
</html>

0 comments on commit 2874490

Please sign in to comment.