code is:
delete_vinyl_form.php
Code: Select all
<?php
//display_vinyl_form.php
require_once('shopping_cart_fns.php');
?>
<script>
function checkIt(){
if(confirm("Delete Vinyl from Shop")){
document.MyForm.submit();
}
}
</script>
<?php
function display_vinyl_form($vinyl = '')
{
$edit = is_array($vinyl);
?>
<center><form align="center" name="newrecord" method="post" enctype="multipart/form-data" action="<?php echo $edit?'edit_vinyl.php' : 'insert_vinyl.php';?>">
<table bordercolor="#FFFFFF" border="1" bgcolor="#7b9815">
<font color="#000000" size="2" face="Courier New, Courier, mono">
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Cat_No: </font></td>
<td><input name="cat_no" type="text" maxlength="6" value="<?php echo $vinylї'cat_no']; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Title: </font></td>
<td><input name="title" type="text" maxlength="40" value="<?php echo $edit?$vinylї'title']:' '; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Artist: </font></td>
<td><select name="artist_id">
<?php
$artist_array=get_artists();
foreach ($artist_array as $thisartist)
{
echo '<option value="';
echo $thisartistї'artist_id'];
echo '"';
if ($edit && $thisartistї'artist_id'] == $vinylї'artist_id'])
echo 'selected';
echo '>';
echo $thisartistї'artist_id'];
echo'</option>';
echo"\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Genre: </font></td>
<td><select name="genre_ref">
<?php
$genre_array=get_genres();
foreach ($genre_array as $thisgenre)
{
echo '<option value="';
echo $thisgenreї'genre_ref'];
echo '"';
if ($edit && $thisgenreї'genre_ref'] == $vinylї'genre_ref'])
echo 'selected';
echo '>';
echo $thisgenreї'genre_ref'];
echo'</option>';
echo"\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Formats: </font></td>
<td><select name="format">
<?php
$format_array=get_formats();
foreach ($format_array as $thisformat)
{
echo '<option value="';
echo $thisformatї'format_type'];
echo '"';
if ($edit && $thisformatї'format_type'] == $vinylї'format_type'])
echo 'selected';
echo '>';
echo $thisformatї'format_type'];
echo'</option>';
echo"\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Month: </font></td>
<td><select name="month"><?php
$nums = range(1, 12);
foreach ($nums as $num)
{
echo '<option value="';
echo $num;
echo '"';
echo '>';
echo $num;
echo '</option>';
echo "\n";
} ?>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Year: </font></td>
<td><select name="year"><?php
$nums = range(1994, 2006);
foreach ($nums as $num)
{
echo '<option value="';
echo $num;
echo '"';
echo '>';
echo $num;
echo '</option>';
echo "\n";
} ?>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Vinyl Status: </font></td>
<td><select name="status_code">
<?php
$status_array=get_status();
foreach ($status_array as $thisstatus)
{
echo '<option value="';
echo $thisstatusї'status_code'];
echo '"';
echo '>';
echo $thisstatusї'status_description'];
echo'</option>';
echo"\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Price: </font></td>
<td><input name="price" type="text" maxlength="5" id="price" value="<?php echo $edit?$vinylї'price']: ' '; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Qty: </font></td>
<td><input name="qty" type="text" maxlength="3" id="qty" value="<?php echo $edit?$vinylї'stock_level']: ' '; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Label: </font></td>
<td><input name="label" type="text" maxlength="30" id="qty" value="<?php echo $edit?$vinylї'label']: ' '; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Comments: </font></td>
<td><input name="short_comments" type="text" maxlength="60" id="short_comments" value="<?php echo $edit?$vinylї'comments']: ' '; ?>"></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Vinyl Information:</font></td><td><textarea name="comments" maxlength="225" cols="60" rows="10"><?php echo $vinylї'vinyl_information']?></textarea></td>
</tr>
<tr>
<td><font color="#FFFFFF" size="2" face="Arial, Helvetica, sans-serif">Image Link:</font></td>
<td align="left"><input type="file" name="picture" size="40"></td>
</tr>
<?php
if($vinylї'image']) {
$size = getImageSize($vinylї'image']);
$width = $sizeї0];
$height = $sizeї1];
?>
<tr>
<td>Image: </td>
<td align="center">
<?php echo '<img src"'.$vinylїimage].'"';?>
width="<?php print $width;?>" height="<?php print $height;?>">
</td>
</tr>
<?php } ?>
<tr>
<td <?php if(!$edit) echo 'colspan="2"'; ?> align="center">
<?php
if ($edit)
echo '<input type="hidden" name="oldcatno" value="'.$vinylї'cat_no'].'">';
?>
<td><input type="submit" value="<?php echo $edit?'Update' : 'Add';?>Record"></form><?php if($edit)
{
echo '';
echo '<form name="MyForm" action="delete_vinyl.php"> ';
echo '<input type="button" value="Delete Vinyl" onClick="checkIt();"> ';
echo '<input type="hidden" name="cat_no" value="'.$vinylї'cat_no'].'">';
echo '</form></td>';
} ?>
</tr>
<table></form> </center>
<div align="left"></div></td>
</tr>
</table></td>
</tr>
</table>
<?
}
do_html_footer();
?>delete_vinyl.php
Code: Select all
<?php
session_start();
require('page.inc');
require_once('update_delete_fns.php');
checkAdminLogin();
$editform = new Page();
$editform -> Display();
display_main_menu();
//$catno = $_GETї'cat_no'];
if (isset($_POSTї'cat_no']))
{
$catno = $_POSTї'cat_no'];
if(delete_vinyl($_POSTї'cat_no']))
echo '<center>Book '.$catno.' was deleted.</center><br />';
else
echo '<center>Book '.$catno.' could not be deleted.</center><br />';
}
do_html_footer();
?>Code: Select all
function delete_vinyl($catno)
// deletes vinyl identfied by it's cat_no from the database
{
$link_id = db_connect();
$query = "delete * from vinyls
where cat_no='$catno'";
$result = @mysql_query($query, $link_id);
if (!$result)
return false;
else
return true;
}