Very close to done with my term project I have been working on/stressing about for days, I just have one small error. My html isn't sending over the values for name and day, and it must be html because when I assign default values to the parameters it sends those to the database. Heres my code.
HTML
<html>
<center><h1><div>Enter the user that you would like to change data for
+ .</div></h1></center>
<form action = "http://127.0.0.1/cgi-bin/change.cgi" method="POST">
<div>Name: <input name="name" size="15"></div>
<div>New phone number: <input name="phone" size="15"></div>
<div>New on-call day: <input name="day" size="15"></div>
<div><input type="submit"></div>
</form>
</html>
CGI
#!/usr/bin/perl -w
use CGI qw(standard);
use DBI();
use DBD::mysql;
use warnings;
use diagnostics;
my $q = CGI->new;
my $name = $q->param('name');
my $number = $q->param('phone');
my $day = $q->param('day');
my $dbh = DBI->connect('dbi:mysql:oncall','webuser','password')
or die "Connection Error: $DBI::errstr\n";
my $sth=$dbh->prepare("UPDATE users SET day = ?, phone =? WHERE na
+me = ?");
$sth->execute($day,$number,$name);
#Disconnecting from database
$dbh->disconnect();
print $q->header,
$q->h1('you submitted the change!'),
$q->end_html;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.