duankuai6586 2019-03-30 15:10
浏览 17

如何将标签传递给POST

Im currently filling a label with a session variable, however i need to use the label data later (send it to another label), or create a new session to do so. However, when i attempt to access the first label, or the session that ive set its tells me its not set. So im assuming the data in the first label is showing but its not actually there?

//this is how im creating the first label

<?php

  include_once "dbcon.php";

  //PERFORMING CHECK IF ALL REQUIRED SESSION VARIABLES ARE SET
  if (isset($_SESSION['s_score1'], $_SESSION['s_score2'], $_SESSION['t_team1'], $_SESSION['t_team2'])) {
    $team1 = $_SESSION['t_team1'];
    $team2 = $_SESSION['t_team2'];
    $score1 = $_SESSION['s_score1'];
    $score2 = $_SESSION['s_score2'];

    if ($score1 == $score2) {
      header("Location: tables.php?table=draw"); //CHECKS IF MATCH IS A DRAW, CANNOT BE A DRAW
      exit();
    }else {
      if ($score1 > $score2){
        echo $_SESSION['t_team1'];
      }else {
        echo $_SESSION['t_team2'];

      }
    }
  }else {
  echo "-";
}
?>

//this is how im printing it

<label name="round2-team1" class="round2-teams">
          <?php include_once "action/winner-script.php";?>
        </label>

the issue appears when i try to use this label above, creating a session variable with it, or moving it to a new label is impossible, its like it doesnt exist, even though i can see it on the page???

<?php

  include_once "dbcon.php";

  //PERFORMING CHECK IF ALL REQUIRED SESSION VARIABLES ARE SET
  if (isset($_SESSION['s_score9'], $_SESSION['s_score10'], $_SESSION['t_team9'], $_SESSION['t_team10'])) {
    $team1 = $_SESSION['t_team9'];
    $team2 = $_SESSION['t_team10'];
    $score1 = $_SESSION['s_score9'];
    $score2 = $_SESSION['s_score10'];

    if ($score1 == $score2) {
      header("Location: tables.php?table=draw"); //CHECKS IF MATCH IS A DRAW, CANNOT BE A DRAW
      exit();
    }else {
      if ($score1 > $score2){
        echo $_SESSION['t_team9'];
      }else {
        echo $_SESSION['t_team10'];

      }
    }
  }else {
  echo "-";
}
?>

This is the script, here i am taking my two labels that are displaying on the page, im determining the winner, and then im displaying the session variable which won the game in a different label on the same page. however, when i try using

<?php
  if (isset($_SESSION['t_team9'])) {
 echo $_SESSION['t_team9'];
}else {
  echo "somethings wrong";
}
  ?>

anywhere on the page where my labels lie, i just get the error something went wrong

ATTEMPTED FIX:

<?php

  include_once "dbcon.php";

  //PERFORMING CHECK IF ALL REQUIRED SESSION VARIABLES ARE SET
  if (isset($_SESSION['s_score13'], $_SESSION['s_score14'], $_SESSION['result'], $_SESSION['result2'])) {
    $team1 = $_SESSION['result'];
    $team2 = $_SESSION['result2'];
    $score1 = $_SESSION['s_score13'];
    $score2 = $_SESSION['s_score14'];

    if ($score1 == $score2) {
      header("Location: tables.php?table=draw"); //CHECKS IF MATCH IS A DRAW, CANNOT BE A DRAW
      exit();
    }else {
      if ($score1 > $score2){
        $team1 = $_SESSION['result'];
        $_SESSION['result5'] = $team1;
      }else {
        $team2 = $_SESSION['result2'];
        $_SESSION['result5'] = $team2;

      }
    }
  }else {
  echo "-";
}
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 目详情-五一模拟赛详情页
    • ¥15 有了解d3和topogram.js库的吗?有偿请教
    • ¥100 任意维数的K均值聚类
    • ¥15 stamps做sbas-insar,时序沉降图怎么画
    • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
    • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
    • ¥15 关于#Java#的问题,如何解决?
    • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
    • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
    • ¥15 cmd cl 0x000007b