FatesCall Posted June 8, 2015 Share Posted June 8, 2015 So I'm trying to submit the name of a teamspeak 3 channel and the one word channels work fine with using $_POST['channel'] but if the string is two words (separated by a space) then it only uses the first word of the string Form.php: <form name="kick" method="POST" action="kick.php"> <select name="channel" id="channel"> <option value="default" name="default" selected>Choose One</option> <?php require_once("Teamspeak3/libraries/TeamSpeak3/TeamSpeak3.php"); $ts3_VirtualServer = TeamSpeak3::factory("serverquery://<username redacted>:<password redacted> @localhost:10011/?server_port=9987"); foreach ($ts3_VirtualServer->channelList() as $ts3_Channel) { echo "<option value=" . $ts3_Channel["channel_name"] . ">" . $ts3_Channel["channel_name"] . "</option>"; } ?> </select> <input type="submit" name="Kick Players"/> </form> Kick.php: <?php session_start(); define('MYSITE', $_SERVER['SERVER_NAME'] . ":8000"); //define what our site is. if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($_POST['channel'] == "default") { header('Location: http://' . MYSITE . '/panel_error.php?reason=default'); exit(); } else { $clients = array(); require_once("Teamspeak3/libraries/TeamSpeak3/TeamSpeak3.php"); $ts3_VirtualServer = TeamSpeak3::factory("serverquery://<username redacted>:<password redacted> @localhost:10011/?server_port=9987"); $channel = $ts3_VirtualServer->channelGetByName($_POST['channel']); foreach($ts3_VirtualServer->clientList() as $client) { if($client['cid'] == $channel->getId()) { $clients[$client->getId()] = $client; } } if(empty($clients)) { header('Location: http://' . MYSITE . '/panel_error.php?reason=noclients'); exit(); } $ts3_VirtualServer->clientKick($clients, TeamSpeak3::KICK_SERVER, "You have been kicked from the server!"); header('Location: http://' . MYSITE . '/panel.php'); exit(); } } EXAMPLE OF PROBLEM: In the drop down list I choose 'Admin Room'.I submit and when I run: $channel = $ts3_VirtualServer->channelGetByName($_POST['channel']); it runs as: $channel = $ts3_VirtualServer->channelGetByName('Admin'); instead of: $channel = $ts3_VirtualServer->channelGetByName('Admin Room'); THE ERROR: C:\path\to\project\kick.php(11): TeamSpeak3_Node_Server->channelGetByName('Admin'); //results in below Fatal error: Uncaught exception 'TeamSpeak3_Adapter_ServerQuery_Exception' with message 'invalid channelID' Link to comment https://forums.phpfreaks.com/topic/296708-submitting-the-form/ Share on other sites More sharing options...
Barand Posted June 8, 2015 Share Posted June 8, 2015 Put quotes round the value eg <option value='Channel name'> If you use only <option value=Channel Name> it will use the first word only. Link to comment https://forums.phpfreaks.com/topic/296708-submitting-the-form/#findComment-1513477 Share on other sites More sharing options...
FatesCall Posted June 8, 2015 Author Share Posted June 8, 2015 Put quotes round the value eg <option value='Channel name'> If you use only <option value=Channel Name> it will use the first word only. I feel like I'm such a noob on these forums because I'm asking so many simple questions. Link to comment https://forums.phpfreaks.com/topic/296708-submitting-the-form/#findComment-1513478 Share on other sites More sharing options...
Barand Posted June 8, 2015 Share Posted June 8, 2015 We have all been there. Link to comment https://forums.phpfreaks.com/topic/296708-submitting-the-form/#findComment-1513480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.