-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdelete.php
More file actions
30 lines (26 loc) · 850 Bytes
/
delete.php
File metadata and controls
30 lines (26 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?php
require_once "db.php";
session_start();
if ( isset($_POST['delete']) && isset($_POST['id']) ) {
$id = mysql_real_escape_string($_POST['id']);
$sql = "DELETE FROM users WHERE id = $id";
mysql_query($sql);
$_SESSION['success'] = 'Record deleted';
header( 'Location: index.php' ) ;
return;
}
$id = mysql_real_escape_string($_GET['id']);
$result = mysql_query("SELECT name,id FROM users WHERE id='$id'");
$row = mysql_fetch_row($result);
if ( $row == FALSE ) {
$_SESSION['error'] = 'Bad value for id';
header( 'Location: index.php' ) ;
return;
}
echo "<p>Confirm: Deleting $row[0]</p>\n";
echo('<form method="post"><input type="hidden" ');
echo('name="id" value="'.$row[1].'">'."\n");
echo('<input type="submit" value="Delete" name="delete">');
echo('<a href="index.php">Cancel</a>');
echo("\n</form>\n");
?>