Advertisement
Guest User

Untitled

a guest
Feb 14th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1.  
  2. <form action="" method="post">
  3.  
  4. <select name="game">
  5. <option value="Counter Strike 1.6">Counter Strike 1.6</option>
  6. <option value="Counter Strike GO">Counter Strike GO</option>
  7. <option value="League of Legends">League of Legends</option>
  8. <option value="Diablo 3">Diablo 3</option>
  9. </select>
  10.  
  11. Number of folks I'm searching for:
  12. <select name="players">
  13. <option value="2">1</option>
  14. <option value="3">2</option>
  15. <option value="3">3</option>
  16. <option value="5">4</option>
  17. <option value="6">5</option>
  18. <option value="7">6</option>
  19. <option value="8">7</option>
  20. <option value="9">8</option>
  21. <option value="10">9</option>
  22. <option value="11">10</option>
  23. <option value="12">11</option>
  24.  
  25. </select>
  26.  
  27. <input type="submit" value="create">
  28. </form>
  29.  
  30. <?php
  31. session_start();
  32.  
  33. $_SESSION['creating_room'] = $_POST['game'].$_POST['players'];;
  34.  
  35. $game = $_POST['game'];
  36. $players = $_POST['players'];
  37. $file = "chatrooms/$game.txt";
  38.  
  39. $servername = getenv('IP');
  40. $username = getenv('C9_USER');
  41. $password = "";
  42. $database = "c9";
  43. $dbport = 3306;
  44.  
  45.  
  46. $db = new mysqli($servername, $username, $password, $database, $dbport);
  47.  
  48.  
  49. if ($db->connect_error) {
  50. die("Connection failed: " . $db->connect_error);
  51. }
  52.  
  53. if($_SESSION['creating_room'] != $_SESSION['created_room'] && isset($_POST['game']) && isset($_POST['players'])){
  54. $sql="INSERT into chat_rooms(name,numofuser,file) Values ('$game','$players','$file')";
  55.  
  56. if ($db->query($sql) === TRUE) {
  57. echo "The room was created successfully";
  58.  
  59. $_SESSION['created_room'] = $_SESSION['creating_room'];
  60.  
  61. } else {
  62. echo "Error: " . $sql . "<br>" . $db->error;
  63. }
  64.  
  65. $fh = fopen("room/$file", 'a+');
  66.  
  67. }
  68. $db->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement