Tak se vyskytl ještě jeden problém nemůžu porovnat $_SESSION v druhém skriptu
První skritp
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="styl.css">
</head>
<body>
<div id="spravce">
<div id ="hlava"></div>
<div id="menu">
</div>
<div id="telo">
<div id="formular">
<form name="myform" action="test.php" method="post">
<?php
$accounts = mysql_connect("localhost" , "root" , "admin" )
or die(mysql_error());
mysql_select_db("otazky" , $accounts);
$sql = "SELECT * FROM rocnikovka ORDER BY RAND() LIMIT 10";
$result = mysql_query($sql, $accounts);
$name=0;
$p=0;
while($row = mysql_fetch_array($result)) {
//ID
$ID = $row['ID'];
//načteni odpovědi
$OdpovedA = $row['OdpovedA'];
$OdpovedB = $row['OdpovedB'];
$OdpovedC = $row['OdpovedC'];
//otazka¨
$otazka = $row['Otazka'];
$spravna = $row['SpravnaOdpoved'];
echo "<h2>$otazka</h2>";
$patt = '<input type="radio" name="%s[$row[ReportID]" value="a<? echo $row[Report ID] ?>">';
$patt2 = '<input type="radio" name="%s[$row[ReportID]" value="b<? echo $row[Report ID] ?>">';
$patt3 = '<input type="radio" name="%s[$row[ReportID]" value="c<? echo $row[Report ID] ?>">';
$name=$name+1;
echo sprintf($patt,$name); echo $OdpovedA;
echo "<br>";
echo sprintf($patt2,$name); echo $OdpovedB;
echo "<br>";
echo sprintf($patt3,$name); echo $OdpovedC;
//spravna odpoved
echo "<br>";
echo $spravna;
$p=$p+1;
$pole[$p]=$spravna;
echo "<br>";
}
echo $pole[1];
echo $pole[2];
echo $pole[3];
echo $pole[4];
echo $pole[5];
echo $pole[6];
echo $pole[7];
echo $pole[8];
echo $pole[9];
echo $pole[10];
session_start();
$_SESSION["a"] = $pole[1];
$_SESSION["b"] = $pole[2];
$_SESSION["c"] = $pole[3];
$_SESSION["d"] = $pole[4];
$_SESSION["e"] = $pole[5];
$_SESSION["f"] = $pole[6];
$_SESSION["g"] = $pole[7];
$_SESSION["h"] = $pole[8];
$_SESSION["j"] = $pole[9];
$_SESSION["k"] = $pole[10];
?>
<input type="submit" />
</form>
</div>
</div>
<div id="pata"></div>
</div>
</body>
</html>
Druhý skript :
<html>
<body>
<?php
$cislo=0;
$c=0;
$cikl[1]="d";
$cikl[2]="d";
$cikl[3]="d";
$cikl[4]="d";
$cikl[5]="d";
$cikl[6]="d";
$cikl[7]="d";
$cikl[8]="d";
$cikl[9]="d";
$cikl[10]="d";
$accounts = mysql_connect("localhost" , "root" , "admin" )
or die(mysql_error());
mysql_select_db("otazky" , $accounts);
$sql = "SELECT * FROM rocnikovka";
$result = mysql_query($sql, $accounts);
while($row = mysql_fetch_array($result)) {
$cislo=$cislo+1;
if (!empty($_POST[$cislo])){
foreach($_POST[$cislo] as $report_id)
{
$c=$c+1;
$cikl[$c]=$report_id;
}
}
}
session_start();
echo $cikl[1];
echo $cikl[2];
echo $cikl[3];
echo $cikl[4];
echo $cikl[5];
echo $cikl[6];
echo $cikl[7];
echo $cikl[8];
echo $cikl[9];
echo $cikl[10];
echo "<br>";
echo $_SESSION["a"];
echo $_SESSION["b"];
echo $_SESSION["c"];
echo $_SESSION["d"];
echo $_SESSION["e"];
echo $_SESSION["f"];
echo $_SESSION["g"];
echo $_SESSION["h"];
echo $_SESSION["j"];
echo $_SESSION["k"];
echo "<br>";
if ($cikl[1] == $_SESSION["a"])
echo "DOBRE";
else
echo "SPATNE";
?>
</body>
</html>
A vždycky, když chcu porovnat $_SESSION["a"] s $cikl[1] tak mi napise "Spatne".
if ($cikl[1] == $_SESSION["a"])
echo "DOBRE";
else
echo "SPATNE";
http://uloz.to/xLAfGEPv/echo-png
(odkaz na obrázek)
Připojen obrázek.
Mělo by to napsat "SPRAVNE"
Budu vděčný jestli mi pomůžete.
Už u toho sedím asi 4 hodiny a nemůžu nic najít.