Jump to content

Need help Deleting/Updating users in a database


MjM8082

Recommended Posts

I have a Database, and I am able to add users. I am trying to figure out how to delete users from my database when the delete button is clicked on. Also I want users to be able to update their information when they click on the update button. This is my code... need help as soon as possible. thanks...

 

This is my page where the update/delete button's are located on...

 

<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>

 

 

This is my database page...

 

<?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
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.