PHP SIMPLE CRUD APPLICATION

========================================================================= |====================== index.php ======================================| ========================================================================= <p> <!--DOCTYPE html--> <html> <head> <title>CRUD</title> </head> <body> <h1 align="center">CRUD APPLICATION</h1><hr> <form action="dbcreate.php" method="POST" align="center"> <input type="text" name="name" placeholder="Name"><br> <input type="text" name="class" placeholder="class"><br> <input type="number" name="roll" placeholder="roll"><br> <input type="submit" value="SUBMIT"> <a href="dbshow.php">Show</a> </form> </body> </html> ========================================================================= |====================== connection.php =================================| ========================================================================= <!--php $conn=new mysqli('localhost','root',"",'php'); if($conn--->connect_error){ die("Eoor to connect".$conn->connect_error); } ?> ========================================================================= |======================== dbcreate.php =================================| ========================================================================= <!--php include ('connection.php'); $sql="insert into reg(name,class,roll) values('$_POST[name]','$_POST[class]','$_POST[roll]')"; if($conn--->query($sql)===False){ echo "Error to insert"; }echo "<script>alert ('Record saved, Do You want to insert ?')</script>"; echo "<script>window.location.assign('index.php')</script>"; ?> ========================================================================= |======================== dbshow.php ===================================| ========================================================================= <!--php include ('connection.php'); $sql="select *from reg"; $result=$conn--->query($sql); if($result->num_rows>0){ echo "<table border='1' cellpadding='10' align='center'>"; echo "<tr> <th>SR</th> <th>NAME</th> <th>CLASS</th> <th>ROLL</th> <th>UPLOAD</th> <th>DELETE</th> </tr>"; while($row=$result->fetch_assoc()){ echo "<tr><td>".$row['sr']."</td>"; echo "<td>".$row['name']."</td>"; echo "<td>".$row['class']."</td>"; echo "<td>".$row['roll']."</td>"; echo "<td>"."<a href='update.php?r=$row[sr]'>Edit</a>"."</td>"; echo "<td>"."<a href='dbdelete.php?r=$row[sr]'>Delete</a>"."</td></tr>"; } } echo "</table>"; ?> ========================================================================= |======================== dbdelete.php =================================| ========================================================================= <!--php include('connection.php'); $sql="delete from reg where sr='$_GET[r]'"; if($conn--->query($sql)===True){ echo "<script>alert('delete Successfull');</script>"; echo "<script>window.location.assign('dbshow.php');</script>"; } ?> ========================================================================= |======================== Update.php =================================| ========================================================================= <!--php include('connection.php'); $sql="select *from reg where sr='$_GET[r]'"; $result=$conn--->query($sql); $row=$result->fetch_assoc(); ?> <!--DOCTYPE html--> <html> <head> <title></title> </head> <body> <h3 align="center">UPDATE PAGE</h3><hr> <form align="center" action="dbupdate.php" method="POST"> <input type="text" name="sr" readonly="true"s value="<?php echo $row['sr']?>"><br> <input type="text" name="name" value="<?php echo $row['name']?>"><br> <input type="text" name="class" value="<?php echo $row['class']?>"><br> <input type="number" name="roll" value="<?php echo $row['roll']?>"><br> <input type="submit" value="UPDATE"> </form> </body> </html> ========================================================================= |========================== dbupdate.php ===============================| ========================================================================= <!--php include('connection.php'); $sql="update reg set name='$_POST[name]',class='$_POST[class]',roll='$_POST[roll]' where sr='$_POST[sr]'"; if($conn--->query($sql)===True){ echo "<script>alert('Update succesfully');</script>"; echo "<script>window.location.assign('dbshow.php');</script>"; } ?> ========================================================================= |=======================================================================| ============================[DataBasee Query]============================ -- phpMyAdmin SQL Dump -- version 4.7.0 -- https://www.phpmyadmin.net/ -- -- Host: 127.0.0.1 -- Generation Time: Jul 17, 2017 at 03:41 AM -- Server version: 10.1.22-MariaDB -- PHP Version: 7.1.4 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8mb4 */; -- -- Database: `php` -- -- -------------------------------------------------------- -- -- Table structure for table `reg` -- CREATE TABLE `reg` ( `sr` int(5) NOT NULL, `name` varchar(50) NOT NULL, `class` varchar(50) NOT NULL, `roll` int(11) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- -- Dumping data for table `reg` -- INSERT INTO `reg` (`sr`, `name`, `class`, `roll`) VALUES (1, 'ALOK Nandan', 'MBA', 152161), (2, 'Rahul', 'BCA', 1216), (3, 'Mohan', 'MCAA', 2345), (4, 'Ranjan singh', 'BBM', 2224); -- -- Indexes for dumped tables -- -- -- Indexes for table `reg` -- ALTER TABLE `reg` ADD PRIMARY KEY (`sr`); -- -- AUTO_INCREMENT for dumped tables -- -- -- AUTO_INCREMENT for table `reg` -- ALTER TABLE `reg` MODIFY `sr` int(5) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;

agyanadda

Author & Editor

Has laoreet percipitur ad. Vide interesset in mei, no his legimus verterem. Et nostrum imperdiet appellantur usu, mnesarchum referrentur id vim.

1 $type={blogger}: