Hello,
I want to insert data through html page. So for that I created two file one is for html page(insertdis. html) and second one is for perl script(insert1. pl).But it could not work. Is it correct way for inserting data in database?
Another option of using PERL-CGI but I do not know about this language so please kindly help me.
Thanks!
insert1.pl
insertdis.html
I want to insert data through html page. So for that I created two file one is for html page(insertdis. html) and second one is for perl script(insert1. pl).But it could not work. Is it correct way for inserting data in database?
Another option of using PERL-CGI but I do not know about this language so please kindly help me.
Thanks!
insert1.pl
Code:
# PERL MODULES WE WILL BE USING
use DBI;
use DBD::mysql;
# CONFIG VARIABLES
$platform = "mysql";
$database = "purchase";
$port = "3306";
$host = "localhost";
$user = "root";
$pw = "";
#DATA SOURCE NAME
$dsn = "dbi:mysql:$database:localhost:3306";
# PERL DBI CONNECT
$DBIconnect = DBI->connect($dsn, $user, $pw)or die "unable to connect:$DBI::errstr\n";
$head=$_POST['head'];
$subhead=$_POST['subhead'];
#PREPARE THE QUERY
$query = "INSERT INTO naipone (head, subhead) VALUES ('$head','$subhead')";
$query_handle = $DBIconnect->prepare($query);
# EXECUTE THE QUERY
$query_handle->execute();
Code:
<html> <head> <body text="#FFFFFF" bgcolor="#800000"> <form method="post" action="insert1.pl"> head:<br/> <input type="text" name="head" size="30"/><br/> subhead:<br/> <input type="text" name="subhead" size="30"/><br/> <input type="submit" value="update" size="30"/> </form> </body> </html>
Comment