Jump to content

Delete User In MySQL


MjM8082

Recommended Posts

How do I delete a user from my MySQL database? When I click the delete button on the website I want the user to be deleted out of the database.

 

Here is my code for the delete button page...

 

<html xmlns="http://www.w3.org/1999/xhtml">

<!-- the head section -->
<head>
    <title>Update User</title>
    
</head>

<!-- the body section -->
<body>
<h1>Update User</h1>

<?php
//echo $_GET['id'];
if (isset($_POST['btn_update']))
{
	echo "My update stuff goes here";
}
else if (isset($_POST['btn_delete']))
{
	echo "My delete stuff goes here";

}
?>


<form name="my_form" method="post" action="update_user.php">
	User Name: <input type="text" name="user_name"><br />
	First Name: <input type="text" name="first_name"><br />
	Last Name: <input type="text" name="last_name"><br />
	Password: <input type="text" name="pwd"><br />
	Admin: <input type="text" name="is_admin">
	<input type="submit" name="btn_update" value="Update User" />
	<input type="submit" name="btn_delete" value="Delete User" />
</form>

</body>
</html>

 

 

here is the database

<?php
    $dsn = 'mysql:host=localhost;dbname=se266';
    $username = 'se266_user';
    $password = 'pwd';

    try {
        $db = new PDO($dsn, $username, $password);
    } catch (PDOException $e) {
        $error_message = $e->getMessage();
        include('database_error.php');
        exit();
    }
?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/243656-delete-user-in-mysql/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.