Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $user = 'root';
- $pass = '';
- $db = 'sample';
- $reg_no="reg_no";
- $name="name";
- $address="address";
- $state="state";
- $db = new mysqli('localhost',$user,$pass, $db) or die("Unable to connect");
- if(isset($_POST['insert']))
- {
- $insert_Query="INSERT INTO sample_tab (reg_no,name,address,state)VALUES('$reg_no','$name','$address','$state')";
- $insert_Result=mysqli_query($db,$insert_Query);
- if(mysqli_affected_rows($db)>0)
- {
- echo'Data Inserted';
- }else{
- echo'Data not inserted';
- }
- }
- mysqli_close($db);
- ?>
- <html>
- <head>
- <title>PHP insert update and delete records.</title>
- </head>
- <body>
- <form action="connect.php" method="post">
- <input type="number" name="reg_no" placeholder="reg no" value="<?php echo $reg_no?>"><br><br>
- <input type="text" name="name" placeholder="name"value="<?php echo $name?>"><br><br>
- <input type="text" name="address" placeholder="address"value="<?php echo $address?>"><br><br>
- <input type="text" name="state" placeholder="state"value="<?php echo $state?>"><br><br>
- <div>
- <input type="submit" name ="insert" value ="Add">
- <input type="submit" name ="update" value ="Update">
- <input type="submit" name ="delete" value ="Delete">
- <input type="submit" name ="search" value ="Search">
- </div>
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement