Jquery and PHP sessions
<p>I'm learning jquery as I code and I need to do something with jquery related to sessions. Code goes like this for html:</p>

<pre><code>&lt;table class="match_table"&gt;
&lt;tr id="10"&gt;&lt;td class="timez"&gt;20:45&lt;/td&gt;&lt;td&gt;Valencia&lt;/td&gt;&lt;td&gt;:&lt;/td&gt;&lt;td&gt;Fulham&lt;/td&gt;&lt;/tr&gt;
&lt;tr id="11"&gt;&lt;td class="timez"&gt;20:45&lt;/td&gt;&lt;td&gt;Crvena Zvezda &lt;/td&gt;&lt;td&gt;:&lt;/td&gt;&lt;td&gt;Rad&lt;/td&gt;&lt;/tr&gt;
&lt;tr id="12"&gt;&lt;td class="timez"&gt;20:45&lt;/td&gt;&lt;td&gt;Vojvodina &lt;/td&gt;&lt;td&gt;:&lt;/td&gt;&lt;td&gt;Elche&lt;/td&gt;&lt;/tr&gt;
&lt;tr id="13"&gt;&lt;td class="timez"&gt;20:45&lt;/td&gt;&lt;td&gt;Chelsea &lt;/td&gt;&lt;td&gt;:&lt;/td&gt;&lt;td&gt;Tottenham&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;

&lt;div id="triping"&gt;
&lt;form id="triping_form"&gt;
&lt;table class="popz"&gt;
&lt;tr&gt;
&lt;td&gt;1&lt;/td&gt;&lt;td&gt;&lt;input type="radio" name="opklada" value="1" /&gt;&lt;/td&gt;
&lt;td&gt;X&lt;/td&gt;&lt;td&gt;&lt;input type="radio" name="opklada" value="2" /&gt;&lt;/td&gt;
&lt;td&gt;2&lt;/td&gt;&lt;td&gt;&lt;input type="radio" name="opklada" value="3" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;0-2&lt;/td&gt;&lt;td&gt;&lt;input type="radio" name="opklada" value="4" /&gt;&lt;/td&gt;
&lt;td&gt;3+&lt;/td&gt;&lt;td&gt;&lt;input type="radio" name="opklada" value="5" /&gt;&lt;/td&gt;
&lt;td&gt;4+&lt;/td&gt;&lt;td&gt;&lt;input type="radio" name="opklada" value="6" /&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;span id="toje" style="display:none"&gt;&lt;img src="success.png" /&gt;&lt;/span&gt;
&lt;input type="hidden" name="match_id" id="hidin" /&gt;
&lt;input type="submit" class="button-class" id="grauzame" /&gt;
&lt;/form&gt;
&lt;/div&gt;
</code></pre>

<p>This is jquery:</p>

<pre><code>&lt;script type="text/javascript"&gt;
      var current_id;
      $('.match_table tr').on('click', function() { 
            $("#triping").slideUp(300);
            $("#triping").slideDown(300);
            current_id = $(this).attr('id');
            $("#hidin").val(current_id);
            $("#toje").hide();
            $("#grauzame").show();
        });

    $("form#triping_form").on("submit", function() { 
        $.post("ajax.php", { match_id: $("#hidin").val() }, function(rez) { 
                    if(rez == 'ok') {
                        $("#grauzame").hide();
                        $("#toje").fadeIn(500);
                    }
        });
        return false;

    });
&lt;/script&gt;
</code></pre>

<p>Now, I will now just simulate user login with opening sessions:</p>

<pre><code>session_start();
$_SESSION['user_id'] = 12;
$_SESSION['username'] = 'eston';
</code></pre>

<p>I know jquery is not nice, but it works for now. I will improve it later. But the point is, logged in user can click on submit button and he will get confirmation image.</p>

<p>I need to prevent send message to guests, like 'You must be logged in to submit' when he clicks on submit. How to make this work together with sessions and what's the best way? I would probably figure it out but it's better to see what are the best practices. But for now any solution is welcome :)</p>
