I have a form that posts some variables with jquery. I'm having trouble getting the php that processes the form to work as intended and can't figure out what I'm doing wrong.
I want the form to do different things depending on the value of the btn
variable but if the user is not logged in (user_session is empty) then a message is returned telling them so. What have I got wrong here?
<?php
session_start();
//Check session is set
if(isset($_SESSION['user_session']) && !empty($_SESSION['user_session'])) {
$btn=$_POST['btn']; //Get btn name from form
if ($btn=="btn_follow") {
//Do something
}
elseif ($btn=='btn_unfollow') {
//Do something else
}
echo "You need to be logged in";
}
?>