Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. <?php
  2. $user = 'root';
  3. $pass = '';
  4. $db = 'sample';
  5. $reg_no="reg_no";
  6. $name="name";
  7. $address="address";
  8. $state="state";
  9.  
  10. $db = new mysqli('localhost',$user,$pass, $db) or die("Unable to connect");
  11.  
  12.  
  13. if(isset($_POST['insert']))
  14. {
  15.  
  16. $insert_Query="INSERT INTO sample_tab (reg_no,name,address,state)VALUES('$reg_no','$name','$address','$state')";
  17.  
  18. $insert_Result=mysqli_query($db,$insert_Query);
  19. if(mysqli_affected_rows($db)>0)
  20. {
  21. echo'Data Inserted';
  22. }else{
  23.  
  24. echo'Data not inserted';
  25. }
  26.  
  27.  
  28. }
  29. mysqli_close($db);
  30. ?>
  31.  
  32.  
  33. <html>
  34. <head>
  35. <title>PHP insert update and delete records.</title>
  36. </head>
  37. <body>
  38. <form action="connect.php" method="post">
  39. <input type="number" name="reg_no" placeholder="reg no" value="<?php echo $reg_no?>"><br><br>
  40. <input type="text" name="name" placeholder="name"value="<?php echo $name?>"><br><br>
  41. <input type="text" name="address" placeholder="address"value="<?php echo $address?>"><br><br>
  42. <input type="text" name="state" placeholder="state"value="<?php echo $state?>"><br><br>
  43. <div>
  44. <input type="submit" name ="insert" value ="Add">
  45. <input type="submit" name ="update" value ="Update">
  46. <input type="submit" name ="delete" value ="Delete">
  47. <input type="submit" name ="search" value ="Search">
  48. </div>
  49. </form>
  50. </body>
  51. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement