PHP $action how to use if with it

Discussion in 'HTML & Website Design' started by Joujouba, Jun 6, 2014.

  1. #1
    Hello,

    I have two submit id, one called id="jump" and the other called id="run"
    the code:
    $action = trim($_GET['id']);
    $action = (empty($action) || $action == '') ? 'jump' : 'run';
    if($action == 'jump')
    {
    xxxxxxx
    xxxxxxx
    xxxxxxx
    }
    if($action == 'run')
    {
    xxxxxxx
    xxxxxxx
    xxxxxxx
    }
    PHP:
    But for some reason its only taking the jump function but not working on the run function.
    Any idea why?

    Thank you!!
     
    Joujouba, Jun 6, 2014 IP
  2. Nilanjan Maity

    Nilanjan Maity Member

    Messages:
    4
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    33
    #2
    Try this..

    $action = trim($_GET['id']);
    $action = (!isset($_GET['id']) || $_GET['id'] == '') ? 'jump' : $action;
    if($action == 'jump')
    {
    echo 'jump';
    }
    if($action == 'run')
    {
    echo 'run';
    }
    PHP:
     
    Last edited by a moderator: Jan 13, 2015
    Nilanjan Maity, Jun 7, 2014 IP
    badmas likes this.