I'm trying to make an address book that takes the data entered by a user in a form, and then sends it to a table in a database. I have no idea if I'm doing it right since I haven't found a whole example of html for and perl code - just snippets. I'm getting an error (I'll post it after the code).
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Address Book</title>
<link rel="stylesheet" href="stylesheet.css">
</head>
<body>
<h2>Address Book</h2>
<form action="test2.pl" name="myForm" method="post">
<fieldset>
<legend>Contact Details</legend>
<div>
<label for="First_Name">First Name: </label>
<input type="text" id="First_Name" name="First_Name" placeholder="John" required><br>
</div>
<div>
<label for="Last_Name">Last Name: </label>
<input type="text" id="Last_Name" name="Last_Name" placeholder="Doe" required><br>
</div>
<div>
<label for="Address">Address: </label>
<input type="text" id="Address" name="Address" placeholder="123 My Street Anytown, US 45678" required><br>
</div>
<div>
<label for="Phone">Phone: </label>
<input <input pattern="(?:\(\d{3}\)|\d{3})[- ]?\d{3}[- ]?\d{4}" id="Phone" name="Phone" placeholder="(xxx)xxx-xxxx" maxlength="13" required> <br>
</div>
<div>
<label for="Birthday">Birthday: </label>
<input type="date" id="Birthday" name="Birthday" value="" required><br>
</div>
<div>
<label for="Email">Email: </label>
<input type="email" id="Email" name="Email" placeholder="johndoe@email.com" required><br>
</div>
<div>
<label for="Relationship">Relationship: </label>
<input type="text" id="Relationship" name="Relationship" placeholder="brother" required><br>
</div>
<div>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</div>
</form>
</body>
</html>
And perl code:
use strict;
use warnings;
use DBI;
print "HTTP/1.0 200 OK\n";
print "Content-Type: text/html\n\n\n";
my $dbh=DBI->connect("DBI:mysql:database=address_book;host=**.**.***.159", "***", "****");
my $o = new CGI;
my $Contact_ID = $o -> param("Contact_ID");
my $First_Name = $o -> param("First_Name");
my $Last_Name = $o -> param("Last_Name");
my $Address = $o -> param("Address");
my $Phone = $o -> param("Phone");
my $Birthday = $o -> param("Birthday");
my $Email = $o -> param("Email");
my $Relationship = $o -> param("Relationship");
$dbh->do("INSERT INTO Contacts VALUES (?, ?, ?, ?, ?, ?, ?, ?)", undef, '0', $First_Name, $Last_Name, $Address, $Phone, $Birthday, $Email, $Relationship);
$dbh->disconnect();
The error:
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are "install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: C:/Program Files (x86)/Parallels/Plesk/Additional/Perl/site/lib C:/Program Files (x86)/Parallels/Plesk/Additional/Perl/lib .) at (eval 3) line 3. Perhaps the DBD::mysql perl module hasn't been fully installed, or perhaps the capitalisation of 'mysql' isn't right. Available drivers: CSV, DBM, ExampleP, File, Gofer, ODBC, Oracle, Proxy, SQLite, Sponge. at G:\PleskVhosts\tonyalesher.com\httpdocs\project\test2.pl line 7 HTTP/1.0 200 OK Content-Type: text/html ".
I downloaded the DBD from my command prompt, but I can't find the folder that it's mentioning - it doesn't exist on my computer. I'm using a godaddy account (plesk) I don't know if that matters. Thank you!