Advertisement
swimmerbhs

Untitled

Apr 23rd, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.53 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     if(!isset($_SESSION['userName'])) //without being logged in you can not do anything
  4.     {
  5.         session_destroy();
  6.         header("location:index.php");
  7.     }
  8.     if(isset($_POST['logout']))
  9. {
  10.         header("location:logout.php"); // log out
  11. }
  12. $result=mysqli_query($con, "select * from Users where `userName` ='$userName'");
  13.     $row = mysqli_fetch_array($result);
  14.     $id = $row['id_cust'];          //gets the username from the session vairables and                                          then will allow it to search the result for their id
  15. include 'database_connector.php'; // databse information
  16. if(isset($_POST['delete']))       // if checkbox in any row will delete
  17. {
  18.     foreach($_POST['checkbox'] as $id)
  19.     {
  20.         $result=mysqli_query($con,"delete from Sports where `id` ='$id'");
  21.         if($result)
  22.             echo "Successfully deleted";
  23.     }
  24. }
  25. if(isset($_POST['update'])){   //if updata is selected with a radio button will keep the
  26. $date1=$_POST['date'];          //values in the variables and pass them to update.php
  27. $event1=$_POST['event'];
  28. $team1a=$_POST['Team 1'];
  29. $team2a=$_POST['Team 2'];
  30. $place1=$_POST['Place'];
  31. $price1=$_POST['Price'];
  32. header("location:update.php");
  33. }
  34. $currenttime=date("Y-m-d");
  35. ?>
  36. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  37. <html xmlns="http://www.w3.org/1999/xhtml">
  38. <head>
  39. <link href="index.css" rel="stylesheet" type="text/css" /> <!--css sytle sheet-->
  40. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  41. <title>Users Page</title>
  42. </head>
  43. <body>
  44. <div id="floatleft"> <!-- float scoreboard to the left and the sign in to the right -->
  45. <iframe src="//www.gamechanger.io/team-52c86f6d1645cf08a4c3ff43/scoreboard?g=5&p=5131254a45506d60704191af" width="728" height="90" scrolling="no" frameborder="0"></iframe>
  46. </div>
  47. <div id="signin">
  48. [ <a href="signup.php">Sign Up</a> ]
  49. [ <a href="signin.php">Sign In</a> ]
  50. [ <a href="logout.php">Log Out</a> ]
  51. </div>
  52. <div id="clear"></div> <!-- clear alignment -->
  53. <div class="navbar"> <!-- Float nav bar to the left and table to the right -->
  54. <ul>
  55. <li><a href="concerts.php" target="_self">Concert</a></li>
  56. <li><a href="restaurants.php" target="_self">Restaurant</a></li>
  57. <li><a href="sports.php" target="_self">Sports</a></li>
  58. <li><a href="users.php" target="_self">Users</a></li>
  59. <li><a href="addconcert.php" target="_self">Add Concerts</a></li>
  60. <li><a href="addrestaurants.php" target="_self">Add Restaurants</a></li>
  61. <li><a href="addsports.php" target="_self">Add Sports</a></li>
  62. </ul>
  63. </div>
  64. <div id="results">
  65. <?php
  66. $result=mysqli_query($con, "select * from Sports where `date` >= '$currenttime' LIMIT 0, 30");
  67. echo "<table>";
  68. echo "<tr>
  69.       <th>Update</th>
  70.       <th>Delete</th>
  71.       <th>Date</th>
  72.       <th>Event Type</th>
  73.       <th>Team 1</th>
  74.       <th>Team 2</th>
  75.       <th>Place</th>
  76.       <th>Price</th>
  77.       </tr>";  
  78. while($rows=mysqli_fetch_array($result)){
  79.  ?>
  80. <tr>
  81. <td align="center"><input name="radio[]" type="radio" value="<? echo $rows['id']; ?>"></td>
  82. <td align="center"><input name="checkbox[]" type="checkbox" value="<? echo $rows['id']; ?>"></td>
  83. <td><? echo $rows['Date']; ?></td>
  84. <td><? echo $rows['event']; ?></td>
  85. <td><? echo $rows['Team 1']; ?></td>
  86. <td><? echo $rows['Team 2']; ?></td>
  87. <td><? echo $rows['Place']; ?></td>
  88. <td><? echo $rows['Price']; ?></td>
  89. </tr>
  90. }
  91. <?php
  92. }
  93. echo "</table>"
  94. ?>
  95. <form name="update" action="users.php" method="post">
  96. <input type="submit" value="delete" name="delete" />
  97. <input type="submit" value="update" name="update" />
  98. </form>
  99. </div>
  100. </body>
  101. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement