Vikhyath_11

w9

Jul 29th, 2024 (edited)
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. cd /usr/lib/cgi-bin
  2. gedit 9.pl
  3. chmod 777 9.pl
  4. cd /var/www/html
  5. gedit 9.html
  6. mysql
  7. create database muz;
  8. use muz;
  9. create table stud (name varchar(20),age int);
  10. select user from mysql.user;
  11. GRANT ALL PREVILEGES ON muz.* TO 'apache' @'localhost';
  12. GRANT ALL PREVILEGES ON muz.stud TO 'apache' @'localhost';
  13. FLUSH PREVILEGES;
  14. exit
  15. browser(link: http://localhost/9.html)
  16.  
  17.  
  18. #! /usr/bin/perl
  19. print "Content-type:text/html\n\n";
  20. print"<HTML><HEAD><TITLE>Student Database</TITLE></HEAD>";
  21. use CGI ':standard';
  22. use DBI;
  23. $dbh=DBI->connect("DBI:mysql:muz","apache","cool");
  24. $name=param("name");
  25. $age=param("age");
  26. $qh=$dbh->prepare("insert into stud values('$name','$age')");
  27. $qh=$dbh->execute();
  28. $qh=$dbh->prepare("select * from stud");
  29. $qh=$dbh-execute();
  30. print "<table border size=1><tr><th>Name</th><th>Age</th></tr>";
  31. while(($name,$age)=$qh->fetchrow())
  32. {
  33. print "<tr><td>$name</td><td>$age</td></tr>";
  34. }
  35. print "</table>";
  36. $qh->finish();
  37. $dbh->disconnect();
  38. print "</HTML>";
  39.  
  40. html file
  41. <html>
  42. <body>
  43. <h2>enter information</h2>
  44. <form action="http://localhost/cgi-bin/10.pl">
  45. name:<input type="text" value="name"><br>
  46. age:<input type="text" value="age"><br>
  47. <input type="submit" >
  48. <input type="reset" >
  49. </form>
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment