Guest User

Untitled

a guest
Apr 1st, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3. <body>
  4.  
  5.  
  6. <form action="index.php" method="post">
  7. FirstName:<input type="text" name="fir"><br>
  8. LastName:<input type="text" name="las"><br>
  9. E-mail:<input type="text" name="email_l"><br>
  10. <input type="submit" name="save">
  11. <input type="submit" name"del_row" value="Delete">
  12. </form>
  13.  
  14. <?php
  15. $servername = "localhost";
  16. $username = "root";
  17. $password = '';
  18. $dbname = "myDB";
  19.  
  20. $conn = mysqli_connect($servername, $username, $password, $dbname);
  21.  
  22. // Check connection
  23. if (!$conn) {
  24. die("Connection failed: " . mysqli_connect_error());
  25. }
  26. else{
  27. echo "Connected successfully";
  28. echo "<br>";
  29. }
  30.  
  31. $fir_del = $_POST['fir'];
  32.  
  33. if(isset($_POST['save'])){
  34. $sql = "INSERT INTO tars (firstname, lastname, email) VALUES
  35. ('".$_POST["fir"]."','".$_POST["las"]."','".$_POST["email_l"]."') ";
  36. $result = mysqli_query($conn,$sql);
  37. }
  38.  
  39.  
  40.  
  41. if(isset($_POST['del_row'])){
  42. $sql_del = "DELETE FROM tars WHERE firstname=".$fir_del." ";
  43. $result_del = mysqli_query($conn,$sql_del) or die(mysqli_error());
  44. }
  45.  
  46. mysqli_close($conn);
  47.  
  48. ?>
  49.  
  50. </body>
  51. </html>
Add Comment
Please, Sign In to add comment