Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="" method="post">
- <select name="game">
- <option value="Counter Strike 1.6">Counter Strike 1.6</option>
- <option value="Counter Strike GO">Counter Strike GO</option>
- <option value="League of Legends">League of Legends</option>
- <option value="Diablo 3">Diablo 3</option>
- </select>
- Number of folks I'm searching for:
- <select name="players">
- <option value="2">1</option>
- <option value="3">2</option>
- <option value="3">3</option>
- <option value="5">4</option>
- <option value="6">5</option>
- <option value="7">6</option>
- <option value="8">7</option>
- <option value="9">8</option>
- <option value="10">9</option>
- <option value="11">10</option>
- <option value="12">11</option>
- </select>
- <input type="submit" value="create">
- </form>
- <?php
- session_start();
- $_SESSION['creating_room'] = $_POST['game'].$_POST['players'];;
- $game = $_POST['game'];
- $players = $_POST['players'];
- $file = "chatrooms/$game.txt";
- $servername = getenv('IP');
- $username = getenv('C9_USER');
- $password = "";
- $database = "c9";
- $dbport = 3306;
- $db = new mysqli($servername, $username, $password, $database, $dbport);
- if ($db->connect_error) {
- die("Connection failed: " . $db->connect_error);
- }
- if($_SESSION['creating_room'] != $_SESSION['created_room'] && isset($_POST['game']) && isset($_POST['players'])){
- $sql="INSERT into chat_rooms(name,numofuser,file) Values ('$game','$players','$file')";
- if ($db->query($sql) === TRUE) {
- echo "The room was created successfully";
- $_SESSION['created_room'] = $_SESSION['creating_room'];
- } else {
- echo "Error: " . $sql . "<br>" . $db->error;
- }
- $fh = fopen("room/$file", 'a+');
- }
- $db->close();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement