i went through this small tutorial, that can be found at
http://rhadmin.org/uw/018.html
i did it all pretty much word for word, except that im using postgresql instead of mysql. it works fine, i can get it webpages to draw any info out of the database. but the problem comes when inserting info INTO it. ive overcome "premature end of script headers" error before, but i cant seem to get past this one.
All the files were done in PICO, so ASCII is not a problem. i CHMOD 777 all the files... and now i'll post the html documents
thanks in advance for any help
dbform.php3: located www/htdocs/
<HTML>
<HEAD>
<TITLE>Insert Database Record</TITLE>
</HEAD>
<BODY>
<DIV ALIGN="center">
<H1>Add Database Record</H1>
<FORM METHOD="post" ACTION="../cgi-bin/dbinsert.php3">
<TABLE BORDER="0">
<TR>
<TD>New Item:</TD>
<TD><INPUT NAME="item"></TD>
</TR>
<TR>
<TD>Vendor:</TD>
<TD><SELECT NAME="vendor" SIZE="1">
<?PHP
$conn = pg_Connect("", "", "", "", "grocery");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
$rc = pg_Exec($conn,
"SELECT vendorcode, vendorname
FROM vendors
ORDER BY vendorname;");
if (!$rc) {
echo "An error occurred.\n";
exit;
}
$i = 0;
while ($result = @pg_fetch_array($rc, $i)) {
echo "\n<OPTION VALUE=\"" .
$result["vendorcode"] .
"\">" .
$result["vendorname"];
$i++;
}
pg_FreeResult($rc);
pg_Close($conn);
?>
</SELECT></TD>
</TR>
<TR>
<TD>Quantity:</TD>
<TD><INPUT NAME="quantity"></TD>
</TR>
</TABLE>
<INPUT TYPE="submit">
</FORM>
</BODY>
</HTML>
dbinsert.php3: located www/cgi-bin/
<HTML>
<HEAD>
<TITLE>Confirm Database Insert</TITLE>
</HEAD>
<BODY>
<DIV ALIGN="center">
<?PHP
$conn = pg_Connect("", "", "", "", "grocery");
if (!$conn) {
echo "An error occurred.\n";
exit;
}
pg_Exec($conn,
"INSERT INTO list (item, vendorcode, quantity)
VALUES ('$item', $vendor, $quantity);");
pg_Close($conn);
?>
Database Updated
</BODY>
</HTML>