SESSION变量不起作用

时间:2014-01-25 10:09:25

标签: php variables session

我有两个php页面:

1.php:

<?php
    session_start();
    $p=$_POST["pChoose"];
    $_SESSION["p"]="bbb";
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
    <title>&#1510;&#1493;&#1500;&#1500;&#1493;&#1514;</title>
    <style>
        td{text-align:center;}
    </style>
    <script>
        var j = 'battleship';
        var mone = 0;
        var p1 = new Array();
        var bid = "a,b,c,d";
        var o = 0;
        for (i = 1; i <= 10; i++) {
            p1[i] = "0,0,0,0,0,0,0,0,0,0,0".split(",");
        }
        function ship(myid, sp) {
            //   document.all[myid].src = document.all['choice'].src;
            //   document.all[j].src = document.all['battleship'].src;
            //   j = sp;
            //   switchships(myid);
        }
        function switchships(electedship) {

        }
        function merge() {
            s = "";
            for (i = 1; i <= 10; i++) {
                for (t = 1; t <= 10; t++) {
                    s = s + p1[i][t] + ",";
                }
            }
            return s;
        }
        function send() {
            merge();
            document.forms[0].array.value = s;
            document.battleships.submit();
        }
        function sea(electedarea) {
            document.all[electedarea].src = document.all['achoice'].src;
            shipid = electedarea.split(",");
            p1[shipid[0]][shipid[1]] = 1;
        }
    </script>
</head>
<body bgcolor=orange dir=rtl>
<!--audio controls="controls" hidden=true autoplay=true>
  <source src="sth.mp3" type="audio/mpeg" />
</audio-->
<form method=post action="http://www.mytree.co.il/sub/2.php" name=battleships>
<div align=center>
<font size=3>
<?php
$con=mysql_connect('localhost','a9238963_data','Gr@@een0');
if(!$con)
{
die("Could not have connected to the server because:".mysql_error());
}
mysql_select_db("edomain_submarine", $con) or die("Could not have connected to the server because:".mysql_error());
echo $p;
$in="UPDATE turns set $p=3";
mysql_query($in,$con);
mysql_query("UPDATE subtemp SET string='none'");
$id=$_POST["id"];
$mid=$_POST["mid"];
if($id==nilus) {
if($mid==1)
{
$in="UPDATE battle set id='nilus',mid=1";
mysql_query($in,$con);
?>
äîô÷ã, àðé îáéà ìôðéê îëúá îàú äåøùééå ðìñåï:
<br>
Hi there! Such a pleasure to meet you!
<br>
àðé äåøùééå ðìñåï. 
<br>
àåéá çãù òåîã áôúç. ùîå ðôåìéàåï. àéåí âãåì äåà òì äîîìëä äîôåàøú åäëáéøä ùìðå.<br>ëåìí éåãòéí îä äôåèðöéàì ùìå.<br>äåà éåëì ìäçøéá àú äàéîôøéä!  äåà éåöà ìéí äúéëåï ëãé ìùáù àú äñçø ùì òí äåãå.<br>éù ìàøåá ìå åìâøåí ìå ìäöèòø òì äîçùáä äùèðéú äæå...
<?php
}
elseif($mid==2)
{
$in="UPDATE battle set id='nilus', mid=2";
mysql_query($in,$con);
?>
äîô÷ã, àðé îáéà ìôðéê îëúá îàú ðôåìéàåï áåðôøèä:
<br>
àåääå, áåðæ'åø, áåðæ'åø! àéæä òåðâ ðôì áçì÷é! ìòáåã òí äîöáéà äîåëùø áéåúø áúåìãåú öøôú! àðé ðôåìéàåï áåðôøèä.
<br>
òúéã äøôåáìé÷ä îåðç òì äîáöò äéîé äîáøé÷ äæä.<br>àí ðåëì ìñì÷ àú áøéèðéä îäéí äúéëåï, äí éäéå ëä çìùéí ùðåëì ìäôéì àåúí áìé îàîöéí. <br>àí ðöìéç ìñëì àú äîñçø äáøéèé òí äåãå – äéí äúéëåï ùìðå, åëê âí áøéèðéä. åéåä ìä ôøðñ!
<?php
}
}
elseif($id==gr) {
if($mid==1)
{
$in="UPDATE battle set id='gr',mid=1";
mysql_query($in,$con);
?>
Greetings, handsome gentleman.
<br>
àðé àìéæáú', îìëú àðâìéä.
<br>
ëåìðå äééðå áèåçéí ùëàùø äàøîãä äñôøãéú, äöé äâãåì ùì äîìê ôìéôä éú÷éó àåúðå, ðôñéã.
<br>
àê áëì æàú, áàåøç ôìà, äöìçðå ìäáéñ àåúí. æäå ä÷øá äàçøåï áîìçîä äæå ùðòøëä ùðéí.
<br>
àí ððöç, ðáññ àú ëáåãðå ëîòöîä îôåàøú åð÷ðä ìðå ùí îôåàø åâãåì. àí ðôñéã, ñôøã úåëì ìäùú÷í, åæä øò îàã.
<br>
àìååä àåúê ìëì àåøê äãøê, â'ðèìîï. áäöìçä.
<?php
}
elseif($mid==2)
{
$in="UPDATE battle set id='gr',mid=2";
mysql_query($in,$con);
?>
äîô÷ã, îëúá îîìê ñôøã, ôìéôä äùðé:
<br>
àåìä, îöáéà ëáéø! àðé ôìéôä.
<br>
ñôøã ìà äééúä îùâùâú éåúø. ìà äééðå çæ÷éí éåúø áëì ääéñèåøéä. òã ùä÷îúé àú äàøîãä äñôøãéú.
<br>
äàøîãä äééúä öøéëä ìäáéñ àú àðâìéä ììà áòéä. äéà òð÷éú - äöé äëé âãåì ùäéä ìðå.
<br>
åáëì æàú, àðâìéä îðöçú. æäå ä÷øá äîëøéò. àí ððöç, òåã éù ñéëåé ùðåëì ìäöéì îùäå îäîàîöéí ùäåù÷òå áîìçîä äæå. àí ìà, ìà ðåëì ìäú÷øá òåã ìàðâìéä.
<br>
àæ, áäöìçä ùéäéä ìê! àìååä àåúê ìëì àåøê äãøê.
<?php
}
}
elseif($id==harbor)
{
if($mid==1) {
$in="UPDATE battle set id='harbor',mid=1";
mysql_query($in,$con);
?>
Hello there, great warlord.
<br>
àðé ôøð÷ìéï øåæååìè, ðùéà àøöåú äáøéú.
<br>
àéððé îáéï àéê äéôðéí äòæå ìäú÷éó àåúðå. ðùàøå áùìåí ìàåøê ëì äîìçîä. æå ùòøåøééä. àí ððöç, ð÷ååä ùäòéîåú äåà çã ôòîé åðéùàø áùìåí. 
<br>
àí ðôñéã... àöèøó ìëåçåú äáøéú. øöéúé ìòùåú æàú îîæîï.
<?php
}
elseif($mid==2)
{
$in="UPDATE battle set id='harbor',mid=2";
mysql_query($in,$con);
?>

<br>
àðé äééøèéå, ÷éñø éôï.
<br>
æä æîï øá ùøöéúé ìäú÷éó àú àøöåú äáøéú. äîñò ùìðå ìäúôùèåú äúøáåú äéôðéú îöìéç. àøöåú äáøéú äéà äîèøä äáàä.
<br>
àí ððöç, ðîùéê áîñò áîìåà äëåç. àí ðôñéã, ðöèøê ìòöåø áîñò...
<br>
áäöìçä, îöáéà ãâåì. àðçðå îàçåøéê.
<?php
}
}
?>
</font>
</div>
<table align=center>
<tr>
<td>&#1510;&#1497; &#1492;&#1502;&#1493;&#1500;&#1491;&#1514;<td><td><td><td>&#1510;&#1497; &#1492;&#1488;&#1493;&#1497;&#1489;<td>
</tr>
<tr>
<td>
<?php
$del="DELETE FROM $p";
mysql_query($del,$con);
print("<table border='1' width=400 height=400 dir=ltr>");
for($tr1=1;$tr1<=10;$tr1++)
{
    print("<tr>");
    $s=$tr1;
        for($td1=1;$td1<=10;$td1++)
            {
                $t=$td1;
                $areaid="$s".",$t";
                print("<td width='35' height='35'><img src='normal.png' id='$areaid' onclick=sea('$areaid') width='35' height='35'></td>");
            }
    print("</tr>");    
}
print("</table>");
?>
<td width=30><td>
<table border="0" width=100 height=100>
<tr><td colspan=3><img src='battleship.png' width='35' height='35' id="1a"><td colspan=3><img src='battleship.png' width='35' height='35' id="2a" onclick="ship('2a','2a')"><td colspan=3><img src='battleship.png' width='35' height='35' id="3a" onclick="ship('3a','3a')"><td colspan=3><img src='battleship.png' width='35' height='35' id="4a" onclick="ship('4a','4a')"></tr>
<tr><td colspan=4><img src='battleship.png' width='70' height='35' id="1b"><td colspan=4><img src='battleship.png' width='70' height='35' id="2b"><td colspan=4><img src='battleship.png' width='70' height='35' id="3b"></tr>
<tr><td colspan=6><img src='battleship.png' width='105' height='35' id="1c"><td colspan=6><img src='battleship.png' width='105' height='35' id="2c"></tr>
<tr><td colspan=12><img src='battleship.png' width='140' height='35' id="1d" onclick="ship('4a','4a')"></tr>
</table>


<td width=30><td>

<?php
print("<table border='1' width=400 height=400>");
for($tr2=1;$tr2<=10;$tr2++)
{
    print("<tr>");
        for($td2=1;$td2<=10;$td2++)
            {
                print("<td width='35' height='35'><img src='normal.png' width='35' height='35'></td>");
            }
    print("</tr>");    
}
print("</table>");
?>
</tr>
</table>
<img width='1' height='1' id='bool' src=bool.png />
<img width='1' height='1' id='normal'src=normal.png />
<img width='1' height='1' id='wrong' src=wrong.png />
<img width='1' height='1' id='injury' src=injury.png />
<img width='1' height='1' id='choice' src=choice.png />
<img src='battleship.png' width='1' height='1' id='battleship' />
<img width='1' height='1' id='achoice' src=choice.png />
<center>
<input type=button onclick="send()" value="&#1492;&#1502;&#1513;&#1498;"> 
<br>
<input type=text name="array" style="visibility:hidden;"/>
</form> 
</center>
</body>
</html>     
?>      

和2.php:

<?php
session_start();
$p=$_SESSION["p"];
echo $_SESSION["p"];
$boardm=$_POST["array"];  
$tempb = split(",",$boardm);
$b0 = array_slice($tempb,0,10);
$b1 = array_slice($tempb,10,20);
$b2 = array_slice($tempb,20,30);
$b3 = array_slice($tempb,30,40);
$b4 = array_slice($tempb,40,50);
$b5 = array_slice($tempb,50,60);
$b6 = array_slice($tempb,60,70);
$b7 = array_slice($tempb,70,80);
$b8 = array_slice($tempb,80,90);
$b9 = array_slice($tempb,90,100);
$b=array($b0,$b1,$b2,$b3,$b4,$b5,$b6,$b7,$b8,$b9);
$con=mysql_connect('localhost','a9238963_data','Gr@@een0') or die("Could not have connected to the server because:".mysql_error());
mysql_select_db("edomain_submarine", $con) or die("Could not have connected to the server because:".mysql_error());
for($i=0;$i<10;$i++) {
    mysql_query("insert into $pg(N,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9) values($i,0,0,0,0,0,0,0,0,0,0)");
}
for($i=0;$i<10;$i++) {
    mysql_query("insert into $p(N,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9) values($i,".$b[$i][0].",".$b[$i][1].",".$b[$i][2].",".$b[$i][3].",".$b[$i][4].",".$b[$i][5].",".$b[$i][6].",".$b[$i][7].",".$b[$i][8].",".$b[$i][9].")");
}
mysql_close($con);
?>
<html>
<head>
</head>
<body>
<script>
    //window.location="http://www.mytree.co.il/sub/3.php";
</script>
</body>
</html>
?>

2.php不回应“bbb”。 有什么东西打断了会话吗? 我以前做了一百万次,我不知道造成这个问题的原因。 这两个页面中实现的元素都没有用会话变量打断我。

0 个答案:

没有答案