Hi folks.
I'm trying to tailor a form page that has multiple submits. I've tried to set up a number of conditions but I'm having trouble with the second query. It just does nothing. Echo does not produce anything. I'm hoping that someone can look at the code and tell me what I may be doing wrong or what I can do to clean it up.
Here's the whole code:
<?php require 'config.php'; ?>
<?php require 'flinfo.php'; ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>FAB Loot - ZG Upload</title>
</head>
<body>
<?php
if (isset($addinfo)): // If the user wants to add information
?>
<form action="<?=$PHP_SELF?>" method="post">
<p>Information:<br />
<input name="name" rows="1" cols="20"> - Member Name<br />
<input name="raids_att" rows="1" cols="20"> - Raids Attended<br />
<input name="raid_bwl" rows="1" cols="20"> - BWL Event Days<br />
<input name="raid_mc" rows="1" cols="20"> - MC Event Days<br />
<input name="raid_zg" rows="1" cols="20"> - ZG Event Days<br />
<input name="raid_other" rows="1" cols="20"> - Other Raid Days<br />
<input type="submit" name="submit_attendance" value="SUBMIT" /></p>
</form>
<form action="<?=$PHP_SELF?>" method="post">
<p>Information:<br />
<input name="name" rows="1" cols="20"> - Member Name<br />
<input name="raid_bwl_nonepic_item" rows="1" cols="20"> - BWL Non-Epic Items<br />
<input name="raid_bwl_epic_item" rows="1" cols="20"> - BWL Epic Items<br />
<input name="raid_mc_nonepic_item" rows="1" cols="20"> - MC Non-Epic Items<br />
<input name="raid_mc_epic_item" rows="1" cols="20"> - MC Epic Items<br />
<input name="raid_zg_coin" rows="1" cols="20"> - ZG Coins<br />
<input name="raid_zg_bijou" rows="1" cols="20"> - ZG Bijous<br />
<input name="raid_zg_primal" rows="1" cols="20"> - ZG Primals<br />
<input name="raid_zg_nonepic_item" rows="1" cols="20"> - ZG Non-Epic Items<br />
<input name="raid_zg_epic_item" rows="1" cols="20"> - ZG Epic Items<br />
<input name="raid_other_item" rows="1" cols="20"> - Other Items<br />
<input name="total_items" rows="1" cols="20"> - Total Items<br />
<input type="submit" name="submit_items" value="SUBMIT" /></p>
</form>
<?php
else: // Default page display
// Connect to the database server
$dbcnx = @mysql_connect("$db_host", "$db_user", "$db_passwd");
if (!$dbcnx) {
echo( "<p>Unable to connect to the " .
"database server at this time.</p>"
);
exit();
}
// Select the fab_loot database
if (! @mysql_select_db("$db_name") ) {
echo( "<p>Unable to locate the fab_loot " .
"database at this time.</p>" );
exit();
}
if ($submit_attendance == "SUBMIT") {
$sql = "UPDATE `fab_loot` SET
`raids_att` = `raids_att` + '$_POST[raids_att]',
`raid_bwl` = `raid_bwl` + '$_POST[raid_bwl]',
`raid_mc` = `raid_mc` + '$_POST[raid_mc]',
`raid_zg` = `raid_zg` + '$_POST[raid_zg]',
`raid_other` = `raid_other` + '$_POST[raid_other]'
WHERE `name` = '$_POST[name]'";
if (@mysql_query($sql)) {
echo("<p>Your raid attendance information has been updated.</p>");
} else {
echo("<p>Error adding submitted fab_loot information: "
.
mysql_error() . "</p>");
}
}
if ($submit_items == "SUBMIT") {
$sql = "INSERT INTO `fab_loot` SET
`raid_bwl_nonepic_item` = `raid_bwl_nonepic_item` + '$_POST[raid_bwl_nonepic_item]',
`raid_bwl_epic_item` = `raid_bwl_epic_item` + '$_POST[raid_bwl_epic_item]',
`raid_mc_nonepic_item` = `raid_mc_nonepic_item` + '$_POST[raid_mc_nonepic_item]',
`raid_mc_epic_item` = `raid_mc_epic_item` + '$_POST[raid_mc_epic_item]',
`raid_zg_coin` = `raid_zg_coin` + '$_POST[raid_zg_coin]',
`raid_zg_bijou` = `raid_zg_bijou` + '$_POST[raid_zg_bijou]',
`raid_zg_primal` = `raid_zg_primal` + '$_POST[raid_zg_primal]',
`raid_zg_nonepic_item` = `raid_zg_nonepic_item` + '$_POST[raid_zg_nonepic_item]',
`raid_zg_epic_item` = `raid_zg_epic_item` + '$_POST[raid_zg_epic_item]',
`raid_other_item` = `raid_other_item` + '$_POST[raid_other_item]'
WHERE `name` = '$_POST[name]'";
if (@mysql_query($sql)) {
$sqltotal = mysql_query("SELECT * WHERE `name` = '$_POST[name]'");
if (!$sqltotal) {
die('Invalid query: ' . mysql_error());
}
echo("<p>Items have been added and totals successfully updated.</p>");
$row = mysql_fetch_row($sqltotal);
echo $row[0];
echo $row[1];
echo $row[2];
echo $row[3];
echo $row[4];
echo $row[5];
echo $row[6];
echo $row[7];
echo $row[8];
echo $row[9];
echo $row[10];
echo $row[11];
echo $row[12];
echo $row[13];
echo $row[14];
echo $row[15];
echo $row[16];
echo $row[17];
echo $row[18];
}
}
// When clicked, this link will load this page
// with the fab_loot submission form displayed.
echo("<p><a href='$PHP_SELF?addinfo=1'>Raids Attended</a></p>");
endif;
?>
</body>
</html>
This set of queries are the problem. The first one runs fine when clicking submit - the second does not.
if ($submit_items == "SUBMIT") {
$sql = "INSERT INTO `fab_loot` SET
`raid_bwl_nonepic_item` = `raid_bwl_nonepic_item` + '$_POST[raid_bwl_nonepic_item]',
`raid_bwl_epic_item` = `raid_bwl_epic_item` + '$_POST[raid_bwl_epic_item]',
`raid_mc_nonepic_item` = `raid_mc_nonepic_item` + '$_POST[raid_mc_nonepic_item]',
`raid_mc_epic_item` = `raid_mc_epic_item` + '$_POST[raid_mc_epic_item]',
`raid_zg_coin` = `raid_zg_coin` + '$_POST[raid_zg_coin]',
`raid_zg_bijou` = `raid_zg_bijou` + '$_POST[raid_zg_bijou]',
`raid_zg_primal` = `raid_zg_primal` + '$_POST[raid_zg_primal]',
`raid_zg_nonepic_item` = `raid_zg_nonepic_item` + '$_POST[raid_zg_nonepic_item]',
`raid_zg_epic_item` = `raid_zg_epic_item` + '$_POST[raid_zg_epic_item]',
`raid_other_item` = `raid_other_item` + '$_POST[raid_other_item]'
WHERE `name` = '$_POST[name]'";
if (@mysql_query($sql)) {
$sqltotal = mysql_query("SELECT * WHERE `name` = '$_POST[name]'");
if (!$sqltotal) {
die('Invalid query: ' . mysql_error());
}
echo("<p>Items have been added and totals successfully updated.</p>");
$row = mysql_fetch_row($sqltotal);
echo $row[0];
echo $row[1];
echo $row[2];
echo $row[3];
echo $row[4];
echo $row[5];
echo $row[6];
echo $row[7];
echo $row[8];
echo $row[9];
echo $row[10];
echo $row[11];
echo $row[12];
echo $row[13];
echo $row[14];
echo $row[15];
echo $row[16];
echo $row[17];
echo $row[18];
}
}