gglgokop1704
Programmer
Plesae how can I insert into postgresql table from a form. I have two files. One is .html form which coolects inputs and the other is .php script which connects to a table and inserts the input data. The code for the form is:
<html>
<body>
<form action="insert.php" method="post">
Criteria ID: <input type="text" name="criteriaid" />
Domain ID: <input type="text" name="domainid" />
Criteria Name: <input type="text" name="criterianame" />
Upper Limit: <input type="text" name="upperlimit" />
Lower Limit: <input type="text" name="lowerlimit" />
Range: <input type="text" name="range" />
Unit: <input type="text" name="unit" />
<input type="submit" />
</form>
</body>
</html>
and the code for the php is:
<?php
// Connecting, selecting database
$dbconn = pg_connect("host=138.250.104.227 dbname=rftDatabase user=globus password=globususer");
// Performing SQL query
$query = "INSERT INTO Criteria_Parameters (CriteriaID,DomainID,Criteria_Name,Upper_Limit,Lower_Limit,Range,Unit) VALUES ($_POST[criteriaid],'$_POST[domainid]','$_POST[criterianame]','$_POST[upperlimit]','$_POST[lowerlimit]','$_POST[range]','$_POST[unit]'";
$query = pg_query($query);
if($query)
echo "inserted successfully!";
else{
echo "There was an error! ".pg_last_error();
}
// Closing connection
pg_close($dbconn);
?>
It does not give any error but it does not insert into my table also.
Any help is appreciated
Gokop
<html>
<body>
<form action="insert.php" method="post">
Criteria ID: <input type="text" name="criteriaid" />
Domain ID: <input type="text" name="domainid" />
Criteria Name: <input type="text" name="criterianame" />
Upper Limit: <input type="text" name="upperlimit" />
Lower Limit: <input type="text" name="lowerlimit" />
Range: <input type="text" name="range" />
Unit: <input type="text" name="unit" />
<input type="submit" />
</form>
</body>
</html>
and the code for the php is:
<?php
// Connecting, selecting database
$dbconn = pg_connect("host=138.250.104.227 dbname=rftDatabase user=globus password=globususer");
// Performing SQL query
$query = "INSERT INTO Criteria_Parameters (CriteriaID,DomainID,Criteria_Name,Upper_Limit,Lower_Limit,Range,Unit) VALUES ($_POST[criteriaid],'$_POST[domainid]','$_POST[criterianame]','$_POST[upperlimit]','$_POST[lowerlimit]','$_POST[range]','$_POST[unit]'";
$query = pg_query($query);
if($query)
echo "inserted successfully!";
else{
echo "There was an error! ".pg_last_error();
}
// Closing connection
pg_close($dbconn);
?>
It does not give any error but it does not insert into my table also.
Any help is appreciated
Gokop