Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cd /usr/lib/cgi-bin
- gedit 9.pl
- chmod 777 9.pl
- cd /var/www/html
- gedit 9.html
- mysql
- create database muz;
- use muz;
- create table stud (name varchar(20),age int);
- select user from mysql.user;
- GRANT ALL PREVILEGES ON muz.* TO 'apache' @'localhost';
- GRANT ALL PREVILEGES ON muz.stud TO 'apache' @'localhost';
- FLUSH PREVILEGES;
- exit
- browser(link: http://localhost/9.html)
- #! /usr/bin/perl
- print "Content-type:text/html\n\n";
- print"<HTML><HEAD><TITLE>Student Database</TITLE></HEAD>";
- use CGI ':standard';
- use DBI;
- $dbh=DBI->connect("DBI:mysql:muz","apache","cool");
- $name=param("name");
- $age=param("age");
- $qh=$dbh->prepare("insert into stud values('$name','$age')");
- $qh=$dbh->execute();
- $qh=$dbh->prepare("select * from stud");
- $qh=$dbh-execute();
- 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>";
- html file
- <html>
- <body>
- <h2>enter information</h2>
- <form action="http://localhost/cgi-bin/10.pl">
- name:<input type="text" value="name"><br>
- age:<input type="text" value="age"><br>
- <input type="submit" >
- <input type="reset" >
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment