Guest User

Untitled

a guest
Nov 21st, 2017
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <?php
  2. if($_SERVER["REQUEST_METHOD"]=="POST"){
  3. $id=$_POST["stdid"];
  4. $id=trim($id);
  5. $id=stripcslashes($id);
  6. $id=htmlspecialchars($id);!
  7.  
  8. $host='localhost';
  9. $user='root';
  10. $pass=null;
  11. $db='libman';
  12. $con=mysqli_connect($host,$user,$pass,$db)or die ("unable to connect");
  13.  
  14. $query="select * from management where id='$id'";
  15. $check=duplicate($query);
  16. if($check!=0){
  17. $sqlinsert="insert into management(id) values ('$id')";
  18. mysqli_query($con,$sqlinsert);
  19.  
  20.  
  21. }else{
  22.  
  23. $del="delete from management where id='$id'";
  24. mysqli_query($con,$del);
  25.  
  26.  
  27. }
  28.  
  29. $sqlsearch="select * from management";
  30. $checker=mysqli_query($con,$sqlsearch);
  31. $rowcount=mysqli_num_rows($checker);
  32. $seat=200-$rowcount;
  33. echo $seat;
  34. echo "<br>";
  35. while($show=mysqli_fetch_array($checker)){
  36.  
  37. echo $show["id"];
  38. echo "<br>";
  39.  
  40. }
  41. }
  42. function duplicate($query){
  43. global $con,$flag;
  44. if(mysqli_query($con,$query)){
  45.  
  46. $res=mysqli_query($con,$query);
  47. return $res;
  48.  
  49. }
  50. if(empty(mysqli_query($con,$query))){
  51. $res=mysqli_query($con,$query);
  52. return $res;
  53. }
  54. }
  55.  
  56. ?>
Add Comment
Please, Sign In to add comment