asimryu

action.php

Jan 10th, 2017
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2. include("dbcon.php");
  3. $act = "";
  4. $id = 0;
  5. $name = "";
  6. $phone = "";
  7. $birth = "";
  8. $email = "";
  9. if( isset($_POST['act']) ){
  10. $act = $_POST['act'];
  11. }
  12. if( isset($_POST['id']) ){
  13. $id = (int)$_POST['id'];
  14. }
  15. if( isset($_POST['name']) ){
  16. $name = $_POST['name'];
  17. }
  18. if( isset($_POST['phone']) ){
  19. $phone = $_POST['phone'];
  20. }
  21. if( isset($_POST['birth']) ){
  22. $birth = $_POST['birth'];
  23. }
  24. if( isset($_POST['email']) ){
  25. $email = $_POST['email'];
  26. }
  27. $count = 0;
  28. if( $act == "delete" ) {
  29. if( $id ) {
  30. $sql = "delete from people where id={$id}";
  31. $rs = $db->query($sql);
  32. $count = $rs->rowCount();
  33. }
  34. } else if( $act == "insert" ) {
  35. if( $name && $phone && $birth && $email ) {
  36. $sql = "insert into people set ";
  37. $sql .= "name='{$name}'";
  38. $sql .= ", phone='{$phone}'";
  39. $sql .= ", birth='{$birth}'";
  40. $sql .= ", email='{$email}'";
  41. $rs = $db->query($sql);
  42. $count = $rs->rowCount();
  43. }
  44. }
  45.  
  46. echo $count;
Advertisement
Add Comment
Please, Sign In to add comment