I hope someone can spot the error I have made in this piece of work as I have looked for ages and cannot. This is part of a website I have developed for some friend who sing for charity events, This page takes input of the event date, venue and details and uploads it to a MySQL database for display on another page. It will happily upload the information and I can delete records, but after a record in created, after the event has taken place, they want to update with the amount of the donations. I have created some new code but when I use it, all I upload to the database is 0.00, not the amount in the DONATIONS text box. It may be something silly, but PHP is not my strong suit as yet. I would appreciate any ideas.
Thanks. The code starts below:
Code: Select all
<!DOCTYPE HTML>
<?php
Include('Includes/sig_connect.php');
IF(isset($_POST['form_sub']))
{
$query = 'INSERT INTO gigs (
DATE, VENUE, DETAILS)
VALUES (
"'.$_POST['DATE'].'",
"'.$_POST['VENUE'].'",
"'.$_POST['DETAILS'].'"
)';
if(!mysql_query($query, $db_link))
{
Echo 'Query failed to run'.mysql_error();
exit;
}
# header('Location: '.$_SERVER['PHP_SELF']);
# exit;
} #End if isset form sub
?>
<html>
<head>
<title> Upcoming Appearances </title>
<br>
<BR>
<link rel="stylesheet" type="text/css" href="wightsupp.css">
<script src="jquery.js">
</script>
<div id="content"></div> </div>
</head>
<BODY background="clouds3.jpg">
<script type="text/javascript">
$(document).ready(function(){
$("tr:nth-child(even)").addClass("red");
$("tr:nth-child(odd)").addClass("yellow");
});
</script>
<?PHP
# Delete Record Here
if(isset($_GET['delete_id']))
{
$query = 'DELETE FROM gigs WHERE ID = "'.$_GET['delete_id'].'"';
if(!mysql_query($query, $db_link))
{
Echo 'Query failed to run'.mysql_error();
exit;
}
} #End if isset delete
if(isset($_POST['update_id']))
{
# $query = 'INSERT INTO gigs (DONATIONS) VALUES ("'.$_POST['DONATIONS'].'") WHERE ID = 41';
$query = 'INSERT INTO gigs (DONATIONS) VALUES ("'.$_POST['DONATIONS'].'") WHERE ID = "'.$_GET['update_id'].'"';
if(!mysql_query($query, $db_link))
{
Echo 'Query failed to run'.mysql_error();
exit;
}
} #End if isset delete
# header('Location: '.$_SERVER['PHP_SELF']);
# exit;
#Add a record Here
IF(isset($_GET['add']))
{
$query = "SELECT * FROM gigs";
$result = mysql_query($query, $db_link);
$row = mysql_fetch_assoc($result);
?>
<Form action = "<?PHP $_SERVER['PHP_SELF']?>" method = "post" name = "ADD" >
<Table name = "add a part" WIDTH = "650">
<TR>
<td><b>DATE</b>
<input type = "text" name = "DATE" ></td><TD></td>
<td><b>VENUE</b>
<input type = "text" name = "VENUE" ></td><TD></td>
<td><B>DETAILS</B>
<input type = "text" name = "DETAILS">
</td>
<td><b>DONATIONS</b>
<input type="text" name="DONATIONS"></td></tr><tr>
<td><input type = "submit" name = "form_sub" value = "Submit Details."></td>
</form>
<?PHP
?>
<?PHP
}// close main if
// ?>
<nav name="addgig" id="add gig">
<a href="<?php $_SERVER['PHP_SELF'] ?>?add">Add Gig DETAILS</a></td></tr><BR><BR>
<br><A HREF="gig_admin.php">Return To Gigs Page<br><br><br></a></td></tr></nav>
<center><table name="gigstable" id="gigstable" border = "1px" cell_padding ="0" >
<tr >
<td align="left" WIDTH = "5">ID</td>
<td align="left" WIDTH = "15">DATE</td>
<td align="center" WIDTH = "125">VENUE</td>
<td align="center" WIDTH = "125">DETAILS</td>
<td align="center" WIDTH = "125">DONATIONS</td>
<td align="center" WIDTH = "5">£££</td>
<td align="center" WIDTH = "5">Del</td>
</tr>
<?php
# Main Display Select
# Starts Here
$query = "SELECT * FROM gigs Order by DATE";
$result = mysql_query($query, $db_link);
while($row = mysql_fetch_assoc($result))
{
?>
<TR>
<td height = "25" width = "5%" align="center">
<a href="<?= $_SERVER['PHP_SELF'].'?edit_id='.$row['ID'] ?>"><?PHP echo $row['ID'] ?></a></td>
<td height = "25" width = "10%" align="center"><?PHP ECHO $row['DATE'] ?></td>
<td height = "25" width = "40%" align="center"><?PHP ECHO $row['VENUE'] ?></td>
<td height = "25" width = "70%" align="center"><?PHP ECHO $row['DETAILS'] ?></td>
<td height="25" width="70%" align="center"><?PHP ECHO $row['DONATIONS']?></td>
<td height = "25" width = "20%" align="left">
<a href="<?= $_SERVER['PHP_SELF'].'?update_id='.$row['ID'] ?>">£</a></td>
<td height = "25" width = "20%" align="left">
<a href="<?= $_SERVER['PHP_SELF'].'?delete_id='.$row['ID'] ?>">x</a></td>
</TR>
<?PHP
} #End while
?>
</table></center>
</body>
</html>