NetAdminTools.com
 
SignalQ Sites:
NetAdminTools - Coprolite - NoNIC - SpotBridge - NAW
RoboCoop - AreWeDown - SolarPower - SysAdminTools
Xfig - Gold Loaf - GeekPapa - FixGMC - MCJ - FixRambler
Categories:
GNU/Linux | Homebrew designs | Perl | Administration | Backup/Recovery | Bugs/Fixes | Certification | Database | Email | File/Print | Hardware | Information Grab Bag | Interoperability | GNU/Linux ABCs | Monitoring | Name Resolution | Network Services | Networking | Remote Control | Security | Desktop | Web | BSD | Solaris | GIAGD | REALbasic

Last 30 Days | Last 60 Days | Last 90 Days | All Articles | RSS | Hail Support


Categories:
·GNU/Linux
·Homebrew designs
·Perl
·Administration
·Backup/Recovery
·Bugs/Fixes
·Certification
·Database
·Email
·File/Print
·Hardware
·Information Grab Bag
·Interoperability
·GNU/Linux ABCs
·Monitoring
·Name Resolution
·Network Services
·Networking
·Remote Control
·Security
·Desktop
·Web
·BSD
·Solaris
·GIAGD
·REALbasic
·All Categories


Deleting Records in MySQL Databases With HTML/PHP
Topic: Database   Posted:2004-01-04
Printer Friendly: Print

spacer
In this article, we updated a troubling record. Well, let's just delete the whole record. In fact, let's delete the record with HTML and PHP!! Easy as pie. First we need a little HTML:

<html>
<head>
<title>SystemsDoc Delete</title>
</head>
<body bgcolor="white">
<form method="POST" action="sysdocdelete.php">
<table>
<col span="1" align="right">
<tr>
<td><font color="blue">UID to delete:</font></td>
<td><input type="text" name="UID" size=100></td>
</tr>
<tr>
<td><input type="submit" value="Submit"></td>
</tr>
</table>
</form>
</body>
</html>

We also need a little PHP:

<?php
foreach($HTTP_POST_VARS as $varname => $value)
$formVars[$varname]=$value;
require_once("config.php");
$db1=mysql_connect($dbhost, $dbuname, $dbpass);
mysql_select_db("sysops");
$query="DELETE FROM systemsdoc WHERE UID = \"".$formVars["UID"]."\"";
$result=mysql_query($query);
mysql_close($db1);
?>
<html>
<head>
<title>SystemsDoc Delete</title>
</head>
<body bgcolor="white">
Record Deleted<br><a href="index.html">click here</a> to return to sysops.
</body>
</html>

Here is what this looks like:





Let's verify the record is gone:

mysql> select manu, model, deploy_date, sernum, sysversion from systemsdoc
-> where UID=8;
Empty set (0.00 sec)
mysql>

Piece of cake!




Please read our Terms of Use
Microsoft, Windows, Windows XP, Windows 2003, Windows 2000, and NT are either trademarks or registered trademarks of Microsoft Corporation. NetAdminTools.com is not affiliated with Microsoft Corporation. Linux is a registered trademark of Linus Torvalds, and refers to the Linux kernel. The operating system of most distributions that contain the Linux kernel is GNU/Linux. All logos and trademarks in this site are property of their respective owner. Copyright 1997-2008 NetAdminTools.com

Created by:
MCJ
MCJ CMS