Help to write two values in $ _SESSION using a single form radio

0

I have this code working perfect for writing to BD:

            <?php
        include '../conexao.php';

        $codigo = $_POST['codigo'];
        $servico = $_POST['servico'];
        $servico_status = $_POST['servico_status'];

        $query = mysql_query("SELECT * FROM menu");
        $res = mysql_fetch_array($query);

        // checar se foi postado algo:
        if (isset($_POST['servico_status'])) { // só entra aqui, se gale_status tiver sido postado
            $link = null;
            $status = 'Não';
            // se a pessoa marcar a opção sim:
            if ($_POST['servico_status'] == 1) {
                $status = 'Sim';
                $link = '<li><a href="'.$res['dominio'].'serv_index.php" class="nav1">'.$res['bot_serv'].'</a></li><li class="divider"></li>';
            }
            // acho que tá faltando definir uma id em seu update.
            $update = mysql_query("UPDATE menu SET servico = '$link', servico_status = '$status'");
            if ($update == '') {
                echo "<script language='javascript'>window.alert('Erro ao Habilitar Link ".$res['bot_serv']."!');</script>";
            } else {
                echo "<meta http-equiv='refresh' content='0; URL= menu_halitar_link.php'>
                          <script language='javascript'>window.alert('Link ".$res['bot_serv']." Habilitado com sucesso!');</script>";
            }
        }

        //  só use: enctype="multipart/form-data" quando o formulário fizer upload de algum arquivo.
        ?>
        <form method="post">
            <label>Habilitar o Link <?php echo $res['bot_serv'];?>?</label><br><br>
            <input type='radio' name='servico_status' value='1' checked="checked"/><label>Sim</label>
            <input type="radio" name="servico_status" value='0'><label>Não</label>
            <input type="submit" value="Atualizar">
        </form>

But I'm trying to create a simulator and I need to adapt this code above so that it writes in two different $ _SESSIONs, in $ _SESSION ['hab_prod'] ['status_prod'] and $ _SESSION ['hab_prod'] [ link_prod '].

Edited Code:

I changed the code and only managed to achieve my goal that is to write the $ _SESSION ['hab_prod'] or $ status_prod Enabled (Yes or No) and the $ link_prod (Button Address), including another Radio, and in PHP by separating the code individually.

On the page I will have to be selecting the two radios to work.

I ask friends if there is another way where I can select a single radio to record the two value's options.

  <?php
  @session_start(); // Inicia a session.

    //pega o valor do botao
    $botao=$_POST['atualizar'];
    //verifica se o botao foi clicado
    if($botao=="Atualizar"){
       $status_prod = $_POST['status_prod'];       
    if(isset($status_prod)) {
        $_SESSION['hab_prod']["status_prod"] = $status_prod;
    }}
    //pega o valor do botao
    $botao=$_POST['atualizar'];
    //verifica se o botao foi clicado
    if($botao=="Atualizar"){
       $link_prod = $_POST['link_prod'];
    if(isset($status_prod)) {
        $_SESSION['hab_prod']["link_prod"] = $link_prod;

    echo "<meta http-equiv='refresh' content='0; URL= menu_halitar_link.php'>
    <script language='javascript'>
    window.alert('Dados atualizados com sucesso!');
    </script>";
    }}
    ?>
        <form method="post">
            <label>Habilitar o Link <?php echo $bot_prod ?>?</label><br><br>
            <input style="margin-left:-66px;" type='radio' name='link_prod'
            value='<li><a href="<?php echo $end ?>prod_index.php" class="nav1"><?php echo $bot_prod ?></a></li><li class="divider"></li>'
            checked="checked"/><label>Sim</label>
            <input type="radio" name="link_prod" value=''><label>Não</label><br />
            <input type='radio' name='status_prod' value='Sim' checked="checked"/><label>Sim</label>
            <input type="radio" name="status_prod" value='Não'><label>Não</label>
            <input type="submit" name="atualizar" value="Atualizar">
        </form>

If anyone can give me a light or even show me how I should do it, I will be grateful.

I'm waiting for good tips, hugs to everyone.

    
asked by anonymous 31.05.2016 / 20:45

0 answers