Multiple form action in 1 form

Discussion in 'PHP' started by web@master24, Aug 7, 2009.

  1. #1
    Hi, im have this form:

    <form action="index.php" method="get">
    					<label for="item"> Video ID:</label>
    					<input name="item" id="item" type="text" size="30"><br>
    					<label for="type">Type:</label>
    					<select id="type" name="type">
    						<option value="0">Format FLV &nbsp;</option>
    						<option value="13">Format 3GP &nbsp;</option>
    						<option value="18">Format MP4</option>
                                        <option value="22">Format MP4 (HD)</option>
    						
    					</select> <label for="btget">&nbsp;</label>
    					<input name="btget" id="btget" type="submit" class="boton" value="Download Video">
    					<br>
    				</form>
    PHP:
    But i want include other option, but i want if the user select that option use another action, how i can do that?
     
    web@master24, Aug 7, 2009 IP
  2. jestep

    jestep Prominent Member

    Messages:
    3,659
    Likes Received:
    215
    Best Answers:
    19
    Trophy Points:
    330
    #2
    You would need to use javascript, to change the action based on some criteria, select list, checkbox, etc...
     
    jestep, Aug 7, 2009 IP
  3. Sergey Popov

    Sergey Popov Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can also place redirect within your action script depending of option selected in form. Like this:

    
    <?php
    
      if($_GET["btget"]){
    
        switch($_GET["type"]){
    
          case '0':
            header("Location: process0.php?item=".urlencode($_GET["item"]));
          break;
    
          case '13':
            header("Location: process13.php?item=".urlencode($_GET["item"]));
          break;
    
          case '18':
            header("Location: process18.php?item=".urlencode($_GET["item"]));
          break;
    
          case '22':
            header("Location: process22.php?item=".urlencode($_GET["item"]));
          break;
    
        }
        exit;
    
      }
    
    ?>
    
    PHP:
     
    Sergey Popov, Aug 7, 2009 IP
  4. oop

    oop Peon

    Messages:
    35
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    also take note of using sessions

    <?php

    session_start();
    $_SESSION['prev_data']['get'] = array_merge($_GET,$_POST);

    if($_GET["btget"]){

    switch($_GET["type"]){

    case '0':
    header("Location: process0.php?item=".urlencode($_GET["item"]));
    break;

    case '13':
    header("Location: process13.php?item=".urlencode($_GET["item"]));
    break;

    case '18':
    header("Location: process18.php?item=".urlencode($_GET["item"]));
    break;

    case '22':
    header("Location: process22.php?item=".urlencode($_GET["item"]));
    break;

    }
    exit;

    }

    ?>
     
    oop, Aug 7, 2009 IP