Jump to content

Recommended Posts

i finally got the program to show what i want but now the delete does not work, it will tell the user that what they have selected to delete has been deleted but does not take it out of the database. I know that I am over looking something but not sure what. I will post the codes that i am useing.

 

checkdates.php- allows the user to enter their first and last name hit submit and it will show them the results for there name with check box next to each result and then a delete link to delete.

  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<?php
/*this program was designed to eliminate paper work for the sift supervisors and the csps that work at Sitel here at loring.
  this program was written and developed by Amy Coppola on July 2007	
*/	
?>
<?php 
include'mysqlconnectsitel.inc.php'; 
?>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Check The Dates</title>
<link href= "links.css" rel="stylesheet" type="text/css"/>
<link href= "general.css" rel="stylesheet" type="text/css"/>

<?php 
function getmonth($m=0) {
return (($m==0 ) ? date('F') : date('F', mktime(0,0,0,$m)));
}
?>

</head>
<body>
<br>

<img src="33720001.jpg" alt="sitel" width="300" height="100" />

<?php
if(isset($_POST['action'])){$action=$_POST['action'];}else{$action="";}
if( $action == 'updated' )
{
  extract ($_POST);
  $todaysDate = date("Y-m-d",time());
  
        

//	Need to query database to see if this request is valid


echo "<p><strong>These are the dates that you have requested off!!!!</strong></p>";


$sql ="SELECT first, last, requestedDate FROM timeoff WHERE last = '$last' AND first = '$first'";
$query=mysql_query($sql) or die("Query failed : " . mysql_error());
while($row = mysql_fetch_assoc($query)) {
echo "<p>";
echo $row['first'] ." ". $row['last']. " ". "  ". $row['requestedDate'];	
echo "<td><input type=\"checkbox\" name=\"deleted_items[]\" "; 
echo "</p>";
}
        
$action="";
$_html ="<tr> 
    <td>$_rw->requestId</td>
    <td>$_rw->first</td>
<td>$_rw->last</td>
<td>$_rw->requestedDate</td>
     <td>
   <a href=\"index.php?id=$_rw->requestId&m=del\">DELETE </a></td>

    </tr>";
echo $_html;
echo "<p><strong>To start at the begining page.<a href='members.php'>Click here</a></strong></p>";
}
else

{
  
  
?>

  <form name='checkdate' method='post' action='checkdates.php'> 
<table width="500" border="0">
    <tr>   
    <td>First Name </td>
    <td><input name="first" type="text" size="20" maxlength="20"></td>
  </tr>
  <tr>
    <td>Last Name </td>
    <td><input name="last" type="text" size="30" maxlength="30"></td>
  </tr>
    
  <tr><td><b>Todays Date:</b></td>
  <td>
   <?php
$todaysDate = date("m-d-Y",time());
echo "$todaysDate";	
?> 
  </td>
</tr> 
          
<tr><td colspan="2" align="center">
<input type= 'hidden' name= 'action' value= 'updated'>					
  		<input type = "submit" name = "submit" value= "Submit">
  </td></tr></table>
  
</form>
<?php
}
?>
</body>
</html>

               

 

index.php has the delete code .

<?php
/*this program was designed to eliminate paper work for the sift supervisors and the csps that work at Sitel here at loring.
  this program was written and developed by Amy Coppola on July 2007	
*/	
?>

<?PHP

include 'mysqlconnectsitel.inc.php';// this has my database connection stuff
if($_GET['m'] == 'del' )
{
$requestId = $_GET['id'];
   $query ="DELETE  FROM timeoff WHERE requestId = '$requestId'";
  $result= mysql_query($query) or die(mysql_error());
   echo" <center><font color=\"#00CC00\">Your Info Was Deleted!</font></center> "; 
}

echo "<p><strong>To start at the begining page.<a href='members.php'>Click here</a></strong></p>";
echo "<p><strong>To check your dates again.<a href ='checkdates.php'>Click here</a></strong></p>";
?>


</body>
</html>

 

if this can be done easier like on one page (which i have tried but then the form does not work) let me know or show me how to do it. any help will be appreciated

Link to comment
https://forums.phpfreaks.com/topic/66574-problem-deleting/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.