PHP Delete Values from database

In  the previous Tutorial we have  inserted few values in database which is available here  . In this Section We are going to delete Values from database with the help of Php . I suggest please read Previous how to inserted value in database.  
Now Lets do Practical:
Step 1: First of all start your wamp/xampp server and open phpmyadmin tool For this open  http://localhost/phpmyadmin  in your browser.

Step 2: Second  click on SQL tab and create a database  named testdb1 and insert two values in it with following script :-

create database testdb;
use  testdb;
create table members(id int primary key auto_increment,name varchar(100),email varchar(200),password varchar(100));
insert into members(name,email,password)values('raggu','raggu@gmail.com','1234'), ('hardik','hardik@gmail.com','1234');


After Successful Creation of database and table you will see success message


Step 3:create a new php document and name it as user_delete.php and save it in server root , in case using wamp save it in www directory or in htdoc when using xampp.

Step 4: write following code in user_delete.php.

 <?php

$conn=mysqli_connect('localhost','root','','jashan');
$sql="delete from members where id='1'";
$success=mysqli_query($conn,$sql);
if($success)echo"Member deleted successfully"; 

?>

Step 5 : open browser and see output http://localhost/user_delete.php 


No comments:

| Designed by Harhiktech