adamkearsley
03-13-2008, 03:32 PM
Hi Guys.
Writing a custom addon for my project.
I need a form that will post its data to the DB.
Ive created the form:
<FORM action="input.php" method="post">
INPUT:
<input type="hidden" name="ID" value="' . $listingID . '"><input type="text" name="bid" />
<input type="submit" />
</form>
This works perfectly and grabs the Listing ID.
Is it possible now to post the results to input.php and use the $listingID within the SQl statement on input.php?
<?php
$con = mysql_connect("localhost","USERNAME","PASSWORD");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DATABASE", $con);
$sql='INSERT INTO default_en_listingsdbelements (listingsdbelements_field_name, listingsdbelements_field_value)
VALUES
('bid','$_POST[bid]') WHERE (listingsdb_id = '$_POST[ID]')';
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "SUCCESS!!";
mysql_close($con)
?>
But this doesnt work :( I need WHERE (listingsdb_id = '$_POST[ID]')'; to find the current listing ID, and post [bid] into the listingsdbelements_field_value and bid as the listingsdbelements_field_name.
Any help?
Writing a custom addon for my project.
I need a form that will post its data to the DB.
Ive created the form:
<FORM action="input.php" method="post">
INPUT:
<input type="hidden" name="ID" value="' . $listingID . '"><input type="text" name="bid" />
<input type="submit" />
</form>
This works perfectly and grabs the Listing ID.
Is it possible now to post the results to input.php and use the $listingID within the SQl statement on input.php?
<?php
$con = mysql_connect("localhost","USERNAME","PASSWORD");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("DATABASE", $con);
$sql='INSERT INTO default_en_listingsdbelements (listingsdbelements_field_name, listingsdbelements_field_value)
VALUES
('bid','$_POST[bid]') WHERE (listingsdb_id = '$_POST[ID]')';
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "SUCCESS!!";
mysql_close($con)
?>
But this doesnt work :( I need WHERE (listingsdb_id = '$_POST[ID]')'; to find the current listing ID, and post [bid] into the listingsdbelements_field_value and bid as the listingsdbelements_field_name.
Any help?