aakash2310

Untitled

Oct 11th, 2022
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php
  2. $conn = mysqli_connect("localhost","root","theaakash");
  3. mysqli_query($conn,"create database EmpDBTest");
  4. $conn = mysqli_connect("localhost","root","theaakash","EmpDBTest");
  5. mysqli_query($conn,"create table emptest(EmpId varchar(30), EmpName varchar(30))");
  6. echo "Done";
  7. if(isset($_POST['sub']))
  8. {
  9. $id = $_POST['eid'];
  10. $name = $_POST['ename'];
  11. $stmt = $conn -> prepare("INSERT INTO emptest (EmpId,EmpName) VALUES (?,?)");
  12. $stmt -> bind_param("ss",$id,$name);
  13. if($stmt->execute())
  14. {
  15. echo "Inserted Successfully !!";
  16. }
  17. else{
  18. echo "Failed To Connect". $conn ->error;
  19. }
  20. }
  21. ?>
  22. <form action="db.php" method="post">
  23. ENter Id :
  24. <input type="text" name="eid" id="">
  25. Enter Name :
  26. <input type="text" name="ename" id="">
  27.  
  28. <input type="submit" name="sub" value="Insert">
  29. </form>
  30.  
Advertisement
Add Comment
Please, Sign In to add comment