if ($_POST['id'] beginsWith "gm") {
$_SESSION['game']=="gmod"
}
if ($_POST['id'] beginsWith "tf2") {
$_SESSION['game']=="tf2"
}
How to do this so it will work?
You could use substring
if(substr($POST['id'],0,3) == 'tf2')
 {
  //Do something
 }
Edit: fixed incorrect function name (substring() used, should be substr())
if (strpos($_POST['id'], "gm") === 0) {
  $_SESSION['game'] ="gmod"
}
if (strpos($_POST['id'],"tf2") === 0) {
  $_SESSION['game'] ="tf2"
}
 
    
    NOT the fastest way to do it but you can use regex
if (preg_match("/^gm/", $_POST['id'])) {
    $_SESSION['game']=="gmod"
}
if (preg_match("/^tf2/, $_POST['id'])) {
    $_SESSION['game']=="tf2"
}
 
    
    function startswith($haystack, $needle){ 
    return strpos($haystack, $needle) === 0;
}
if (startswith($_POST['id'], 'gm')) {
    $_SESSION['game'] = 'gmod';
}
if (startswith($_POST['id'], 'tf2')) {
    $_SESSION['game'] = 'tf2';
}
Note that when assigning values to variable use a single =
